Best JavaScript code snippet using argos
hints.ts
Source:hints.ts
1import { SubgraphASTNode } from "@apollo/federation-internals";2import { printLocation } from "graphql";3export enum HintLevel {4 WARN = 60,5 INFO = 40,6 DEBUG = 20,7}8export type HintCodeDefinition = {9 code: string,10 // Note that we keep the name separately, because while it can be obtained easily enough11 // with `HintLevel[value]` on the JS/TS-side, the name would otherwise be lost when12 // serializing the related objects to JSON for rover.13 level: { value: HintLevel, name: string},14 description: string,15}16function makeCodeDefinition({17 code,18 level,19 description,20}: {21 code: string,22 level: HintLevel,23 description: string,24}): HintCodeDefinition {25 return ({26 code,27 level: { value: level, name: HintLevel[level]},28 description,29 });30};31const INCONSISTENT_BUT_COMPATIBLE_FIELD_TYPE = makeCodeDefinition({32 code: 'INCONSISTENT_BUT_COMPATIBLE_FIELD_TYPE',33 level: HintLevel.INFO,34 description: 'Indicates that a field does not have the exact same types in all subgraphs, but that the types are "compatible"'35 + ' (2 types are compatible if one is a non-nullable version of the other, a list version, a subtype, or a'36 + ' combination of the former).',37});38const INCONSISTENT_BUT_COMPATIBLE_ARGUMENT_TYPE = makeCodeDefinition({39 code: 'INCONSISTENT_BUT_COMPATIBLE_ARGUMENT_TYPE',40 level: HintLevel.INFO,41 description: 'Indicates that an argument type (of a field/input field/directive definition) does not have the exact same type'42 + ' in all subgraphs, but that the types are "compatible" (two types are compatible if one is a non-nullable'43 + ' version of the other, a list version, a subtype, or a combination of the former).',44});45const INCONSISTENT_DEFAULT_VALUE_PRESENCE = makeCodeDefinition({46 code: 'INCONSISTENT_DEFAULT_VALUE_PRESENCE',47 level: HintLevel.WARN,48 description: 'Indicates that an argument definition (of a field/input field/directive definition) has a default value in only'49 + ' some of the subgraphs that define the argument.',50});51const INCONSISTENT_ENTITY = makeCodeDefinition({52 code: 'INCONSISTENT_ENTITY',53 level: HintLevel.INFO,54 description: 'Indicates that an object is declared as an entity (has a `@key`) in only some of the subgraphs in which the object is defined.',55});56const INCONSISTENT_OBJECT_VALUE_TYPE_FIELD = makeCodeDefinition({57 code: 'INCONSISTENT_OBJECT_VALUE_TYPE_FIELD',58 level: HintLevel.DEBUG,59 description: 'Indicates that a field of an object "value type" (has no `@key` in any subgraph) is not defined in all the subgraphs that declare the type.',60});61const INCONSISTENT_INTERFACE_VALUE_TYPE_FIELD = makeCodeDefinition({62 code: 'INCONSISTENT_INTERFACE_VALUE_TYPE_FIELD',63 level: HintLevel.DEBUG,64 description: 'Indicates that a field of an interface "value type" (has no `@key` in any subgraph) is not defined in all the subgraphs that declare the type.',65});66const INCONSISTENT_INPUT_OBJECT_FIELD = makeCodeDefinition({67 code: 'INCONSISTENT_INPUT_OBJECT_FIELD',68 level: HintLevel.WARN,69 description: 'Indicates that a field of an input object type definition is only defined in a subset of the subgraphs that declare the input object.',70});71const INCONSISTENT_UNION_MEMBER = makeCodeDefinition({72 code: 'INCONSISTENT_UNION_MEMBER',73 level: HintLevel.DEBUG,74 description: 'Indicates that a member of a union type definition is only defined in a subset of the subgraphs that declare the union.',75});76const INCONSISTENT_ENUM_VALUE_FOR_INPUT_ENUM = makeCodeDefinition({77 code: 'INCONSISTENT_ENUM_VALUE_FOR_INPUT_ENUM',78 level: HintLevel.WARN,79 description: 'Indicates that a value of an enum type definition (that is only used as an Input type) has not been merged into the supergraph because it is defined in only a subset of the subgraphs that declare the enum',80});81const INCONSISTENT_ENUM_VALUE_FOR_OUTPUT_ENUM = makeCodeDefinition({82 code: 'INCONSISTENT_ENUM_VALUE_FOR_OUTPUT_ENUM',83 level: HintLevel.DEBUG,84 description: 'Indicates that a value of an enum type definition (that is only used as an Output type, or is unused) has been merged in the supergraph but is defined in only a subset of the subgraphs that declare the enum',85});86const INCONSISTENT_TYPE_SYSTEM_DIRECTIVE_REPEATABLE = makeCodeDefinition({87 code: 'INCONSISTENT_TYPE_SYSTEM_DIRECTIVE_REPEATABLE',88 level: HintLevel.DEBUG,89 description: 'Indicates that a type system directive definition is marked repeatable in only a subset of the subgraphs that declare the directive (and will be repeatable in the supergraph).',90});91const INCONSISTENT_TYPE_SYSTEM_DIRECTIVE_LOCATIONS = makeCodeDefinition({92 code: 'INCONSISTENT_TYPE_SYSTEM_DIRECTIVE_LOCATIONS',93 level: HintLevel.DEBUG,94 description: 'Indicates that a type system directive definition is declared with inconsistent locations across subgraphs (and will use the union of all locations in the supergraph).',95});96const INCONSISTENT_EXECUTABLE_DIRECTIVE_PRESENCE = makeCodeDefinition({97 code: 'INCONSISTENT_EXECUTABLE_DIRECTIVE_PRESENCE',98 level: HintLevel.WARN,99 description: 'Indicates that an executable directive definition is declared in only some of the subgraphs.',100});101const NO_EXECUTABLE_DIRECTIVE_LOCATIONS_INTERSECTION = makeCodeDefinition({102 code: 'NO_EXECUTABLE_DIRECTIVE_INTERSECTION',103 level: HintLevel.WARN,104 description: 'Indicates that, for an executable directive definition, no location for it appears in all subgraphs.',105});106const INCONSISTENT_EXECUTABLE_DIRECTIVE_REPEATABLE = makeCodeDefinition({107 code: 'INCONSISTENT_EXECUTABLE_DIRECTIVE_REPEATABLE',108 level: HintLevel.WARN,109 description: 'Indicates that an executable directive definition is marked repeatable in only a subset of the subgraphs (and will not be repeatable in the supergraph).',110});111const INCONSISTENT_EXECUTABLE_DIRECTIVE_LOCATIONS = makeCodeDefinition({112 code: 'INCONSISTENT_EXECUTABLE_DIRECTIVE_LOCATIONS',113 level: HintLevel.WARN,114 description: 'Indicates that an executiable directive definition is declared with inconsistent locations across subgraphs (and will use the intersection of all locations in the supergraph).',115});116const INCONSISTENT_DESCRIPTION = makeCodeDefinition({117 code: 'INCONSISTENT_DESCRIPTION',118 level: HintLevel.WARN,119 description: 'Indicates that an element has a description in more than one subgraph, and the descriptions are not equal.',120});121const INCONSISTENT_ARGUMENT_PRESENCE = makeCodeDefinition({122 code: 'INCONSISTENT_ARGUMENT_PRESENCE',123 level: HintLevel.WARN,124 description: 'Indicates that an optional argument (of a field or directive definition) is not present in all subgraphs and will not be part of the supergraph.',125});126const FROM_SUBGRAPH_DOES_NOT_EXIST = makeCodeDefinition({127 code: 'FROM_SUBGRAPH_DOES_NOT_EXIST',128 level: HintLevel.WARN,129 description: 'Source subgraph specified by @override directive does not exist',130});131const OVERRIDDEN_FIELD_CAN_BE_REMOVED = makeCodeDefinition({132 code: 'OVERRIDDEN_FIELD_CAN_BE_REMOVED',133 level: HintLevel.INFO,134 description: 'Field has been overridden by another subgraph. Consider removing.',135});136const OVERRIDE_DIRECTIVE_CAN_BE_REMOVED = makeCodeDefinition({137 code: 'OVERRIDE_DIRECTIVE_CAN_BE_REMOVED',138 level: HintLevel.INFO,139 description: 'Field with @override directive no longer exists in source subgraph, the directive can be safely removed',140});141const UNUSED_ENUM_TYPE = makeCodeDefinition({142 code: 'UNUSED_ENUM_TYPE',143 level: HintLevel.DEBUG,144 description: 'Indicates that an enum type is defined in some subgraphs but is unused (no field/argument references it). All the values from subgraphs defining that enum will be included in the supergraph.',145});146const INCONSISTENT_NON_REPEATABLE_DIRECTIVE_ARGUMENTS = makeCodeDefinition({147 code: 'INCONSISTEN_NON_REPEATABLE_DIRECTIVE_ARGUMENTS',148 level: HintLevel.WARN,149 description: 'A non-repeatable directive is applied to a schema element in different subgraphs but with arguments that are different.',150});151const DIRECTIVE_COMPOSITION_INFO = makeCodeDefinition({152 code: 'DIRECTIVE_COMPOSITION_INFO',153 level: HintLevel.INFO,154 description: 'Indicates that an issue was detected when composing custom directives.',155});156const DIRECTIVE_COMPOSITION_WARN = makeCodeDefinition({157 code: 'DIRECTIVE_COMPOSITION_WARN',158 level: HintLevel.WARN,159 description: 'Indicates that an issue was detected when composing custom directives.',160});161export const HINTS = {162 INCONSISTENT_BUT_COMPATIBLE_FIELD_TYPE,163 INCONSISTENT_BUT_COMPATIBLE_ARGUMENT_TYPE,164 INCONSISTENT_DEFAULT_VALUE_PRESENCE,165 INCONSISTENT_ENTITY,166 INCONSISTENT_OBJECT_VALUE_TYPE_FIELD,167 INCONSISTENT_INTERFACE_VALUE_TYPE_FIELD,168 INCONSISTENT_INPUT_OBJECT_FIELD,169 INCONSISTENT_UNION_MEMBER,170 INCONSISTENT_ENUM_VALUE_FOR_INPUT_ENUM,171 INCONSISTENT_ENUM_VALUE_FOR_OUTPUT_ENUM,172 INCONSISTENT_TYPE_SYSTEM_DIRECTIVE_REPEATABLE,173 INCONSISTENT_TYPE_SYSTEM_DIRECTIVE_LOCATIONS,174 INCONSISTENT_EXECUTABLE_DIRECTIVE_PRESENCE,175 NO_EXECUTABLE_DIRECTIVE_LOCATIONS_INTERSECTION,176 INCONSISTENT_EXECUTABLE_DIRECTIVE_REPEATABLE,177 INCONSISTENT_EXECUTABLE_DIRECTIVE_LOCATIONS,178 INCONSISTENT_DESCRIPTION,179 INCONSISTENT_ARGUMENT_PRESENCE,180 FROM_SUBGRAPH_DOES_NOT_EXIST,181 OVERRIDDEN_FIELD_CAN_BE_REMOVED,182 OVERRIDE_DIRECTIVE_CAN_BE_REMOVED,183 UNUSED_ENUM_TYPE,184 INCONSISTENT_NON_REPEATABLE_DIRECTIVE_ARGUMENTS,185 DIRECTIVE_COMPOSITION_INFO,186 DIRECTIVE_COMPOSITION_WARN,187}188export class CompositionHint {189 public readonly nodes?: readonly SubgraphASTNode[];190 constructor(191 readonly definition: HintCodeDefinition,192 readonly message: string,193 nodes?: readonly SubgraphASTNode[] | SubgraphASTNode194 ) {195 this.nodes = nodes196 ? (Array.isArray(nodes) ? (nodes.length === 0 ? undefined : nodes) : [nodes])197 : undefined;198 }199 toString(): string {200 return `[${this.definition.code}]: ${this.message}`201 }202}203/**204 * Prints a composition hint to a string, alongside useful location information205 * about relevant positions in the subgraph sources.206 */207export function printHint(hint: CompositionHint): string {208 let output = hint.toString();209 if (hint.nodes) {210 for (const node of hint.nodes) {211 if (node.loc) {212 output += '\n\n' + printLocation(node.loc);213 }214 }215 }216 return output;...
product.service.ts
Source:product.service.ts
1import { Injectable } from '@angular/core';2import { Observable, of } from 'rxjs';3import { environment } from 'src/environments/environment';4import { DropDownMenuOption, DropDownMenuOptionStringId, HeaderCountDTO, ProductDTO } from '../DTOs/productDTO';5import { HttpClient, HttpHeaders } from '@angular/common/http';6import { catchError, map, tap } from 'rxjs/operators';7import { PagedDTO } from '../DTOs/pagedDTO';8import { ProductInconsistentDTO } from '../DTOs/productInconsistentDTO';9import { forEach } from '@angular/router/src/utils/collection';10import { ComponentDTO, ProductComponentDTO, ProductComponentInconsistentDTO } from '../DTOs/productComponentDTO';11@Injectable({12 providedIn: 'root'13})14export class ProductService {15 productsUrl = environment.backend + 'products.json';16 productUrl = environment.backend + 'product.json';17 componentsUrl = environment.backend + 'productCompontents.json';18 httpOptions = {19 headers: new HttpHeaders({ 'Content-Type': 'application/json' }),20 };21 // converts dropdown options (id+description) from the json object, which are defined as objects instead of arrays.22 convertDropDownMenuOptions(inconsistentObject: Object): DropDownMenuOption[] {23 const dropDownMenuOptions = [];24 Object.values(inconsistentObject).forEach(element => {25 const newOption = new DropDownMenuOption;26 newOption.id = element.id;27 newOption.description = element.description;28 dropDownMenuOptions.push(newOption);29 });30 return dropDownMenuOptions;31 }32 // same as convertDropDownMenuOptions, but headerCount has a string for an id, so needs a different conversion.33 convertDropDownMenuOptionsWithStringId(inconsistentObject: Object): DropDownMenuOptionStringId[] { 34 const dropDownMenuOptions = [];35 Object.values(inconsistentObject).forEach(element => {36 const newOption = new DropDownMenuOptionStringId;37 newOption.id = element.id;38 newOption.description = element.description;39 dropDownMenuOptions.push(newOption);40 });41 return dropDownMenuOptions;42 }43 // converts a number to a boolean44 convertBoolean(number: number): boolean {45 let result = false; // defaults to false46 if (number==1) {47 result = true;48 }49 return result;50 }51 getProducts(): Observable<PagedDTO<ProductDTO>> {52 return this.http.get<PagedDTO<ProductDTO>>(this.productsUrl , this.httpOptions).pipe(53 tap(() => this.log('fetched products')),54 catchError(this.handleError<PagedDTO<ProductDTO>>('getProducts'))55 );56 }57 58 getProduct(): Observable<ProductDTO> {59 return this.http.get<ProductInconsistentDTO>(this.productUrl , this.httpOptions).pipe(60 tap(() => this.log('fetched products')),61 // mapping inconsistent product onto proper product62 map((response) => {63 return this.convertInconsistentProduct(response);64 }),65 catchError(this.handleError<ProductDTO>('getProducts'))66 );67 }68 getComponents(): Observable<ProductComponentDTO> {69 return this.http.get<ProductComponentInconsistentDTO>(this.componentsUrl , this.httpOptions).pipe(70 tap(() => this.log('fetched components')),71 // mapping inconsistent product onto proper product72 map((response) => {73 return this.convertInconsistentProductComponents(response);74 }),75 catchError(this.handleError<ProductComponentDTO>('getComponents'))76 );77 }78 /**79 * Returns a properly formatted productDTO.80 * @param inconsistent the inconsistent product from the backend81 */82 convertInconsistentProduct(inconsistent: ProductInconsistentDTO): ProductDTO{83 // this function renames certain variables to be consistent with the json list of products, as well as being consistent with itself.84 // found consistency errors such as: 85 // - inconsistent use of lower and upper case86 // - using numbers for booleans87 // - inconsistent use of plurality (the word 'level' for an array of 'levels')88 // - lists like print/change/tag types are object lists, not array lists, so they need to be converted to arrays.89 const product = new ProductDTO;90 product.productId = inconsistent.ProductId;91 product.productKey = inconsistent.ProductKey;92 product.description = inconsistent.Description;93 product.error = inconsistent.error;94 product.growlMessage = inconsistent.GrowlMessage;95 product.growlType = inconsistent.GrowlType;96 product.groupNumber = inconsistent.GroupNumber;97 product.agpNumber = inconsistent.AgpNumber;98 product.length = inconsistent.Length;99 product.width = inconsistent.Width;100 product.height = inconsistent.Height;101 product.weight = inconsistent.Weight;102 product.weightAwms = inconsistent.WeightAwms;103 product.headerVolumeWeightCalc = inconsistent.HeaderVolumeWeightCalc;104 product.headerVolumeWeightUpdated = inconsistent.HeaderVolumeWeightUpdated;105 product.labelRow1 = inconsistent.LabelRow1;106 product.labelRow2 = inconsistent.LabelRow2;107 product.qrRow1 = inconsistent.QrRow1;108 product.qrRow2 = inconsistent.QrRow2;109 product.printTypeId = inconsistent.PrintTypeId;110 product.serviceGroupId = inconsistent.ServiceGroupId;111 product.tuv = inconsistent.TUV;112 product.tuvGroupId = inconsistent.TUVGroupId;113 product.propertyGroupId = inconsistent.PropertieGroupId;114 product.levelId = inconsistent.LevelId;115 product.image = inconsistent.Image; 116 product.mainItem = inconsistent.MainItem;117 product.printTypes = inconsistent.printTypes;118 product.changeTypes = inconsistent.changeTypes;119 //converting objects to java objects120 product.tagTypes = this.convertDropDownMenuOptions(inconsistent.tagTypes);121 product.serviceGroups = this.convertDropDownMenuOptions(inconsistent.serviceGroups);122 product.rssiLevels = this.convertDropDownMenuOptions(inconsistent.RssiLevel)123 product.tuvGroups = this.convertDropDownMenuOptions(inconsistent.TUVGroups);124 product.propertyGroups = this.convertDropDownMenuOptions(inconsistent.PropertyGroups);125 product.headerCount = this.convertDropDownMenuOptionsWithStringId(inconsistent.headerCount); 126 127 // converting to boolean128 product.ov = this.convertBoolean(inconsistent.OV);129 product.emballage = this.convertBoolean(inconsistent.Emballage);130 product.pallet = this.convertBoolean(inconsistent.Pallet);131 product.flightcase = this.convertBoolean(inconsistent.Flightcase);132 product.defaultPhlippo = this.convertBoolean(inconsistent.DefaultPhlippo);133 product.nen = this.convertBoolean(inconsistent.NEN);134 // converting numerical rights to booleans135 product.changeSG = this.convertBoolean(inconsistent.changeSG);136 product.setInspections = this.convertBoolean(inconsistent.setInspections);137 product.addProperties = this.convertBoolean(inconsistent.addProperties);138 product.delProperties = this.convertBoolean(inconsistent.delProperties);139 product.editQR = this.convertBoolean(inconsistent.editQR);140 product.changePG = this.convertBoolean(inconsistent.changePG);141 product.setProperties = this.convertBoolean(inconsistent.SetProperties);142 product.changePL = this.convertBoolean(inconsistent.changePL);143 product.loadComponents = this.convertBoolean(inconsistent.LoadComponents);144 product.changeAgpNumber = this.convertBoolean(inconsistent.editAgpNumber);145 product.changeChangeType = this.convertBoolean(inconsistent.changeChangeType);146 product.changeTagType = this.convertBoolean(inconsistent.changeTagType);147 product.productTagTypeId = this.convertBoolean(inconsistent.ProductTagTypeId);148 product.changeProductIdChanged = this.convertBoolean(inconsistent.changeProductIdChanged);149 product.productIdChanged = this.convertBoolean(inconsistent.ProductIdChanged);150 product.seeProductIdChanged = this.convertBoolean(inconsistent.SeeProductIdChanged);151 product.changeProductId = this.convertBoolean(inconsistent.ChangeProductId);152 product.changeLevelId = this.convertBoolean(inconsistent.changeLevelId);153 return product;154 }155 /**156 * Returns a proper and consistent ProductComponentDTO157 * @param inconsistent the inconsistent ProductComponentInconsistentDTO158 */159 convertInconsistentProductComponents(inconsistent: ProductComponentInconsistentDTO): ProductComponentDTO{160 // this function renames certain variables to be consistent, as well as being consistent with itself.161 // found consistency errors such as: 162 // - inconsistent use of lower and upper case163 // - using numbers for booleans164 const productComponents = new ProductComponentDTO;165 productComponents.error = this.convertBoolean(inconsistent.error);166 productComponents.growlMessage = inconsistent.GrowlMessage;167 productComponents.growlType = inconsistent.GrowlType;168 productComponents.mainItem = inconsistent.MainItem;169 productComponents.setItem = inconsistent.SetItem;170 productComponents.changeRFID = inconsistent.ChangeRFID;171 // initialize component list172 productComponents.components = [];173 // convert inconsistent component list to proper componentlist174 inconsistent.Components.forEach(inconsistentComponent => {175 const component = new ComponentDTO;176 component.error = this.convertBoolean(inconsistentComponent.error);177 component.productKey = inconsistentComponent.ProductKey;178 component.description = inconsistentComponent.Description;179 component.quantity = inconsistentComponent.Quantity;180 component.ondemand = this.convertBoolean(inconsistentComponent.Ondemand);181 component.serialitem = inconsistentComponent.Serialitem;182 productComponents.components.push(component);183 });184 return productComponents;185 }186 handleError<T>(operation = 'operation', result?: T) {187 return (error: any): Observable<T> => {188 console.error(error); // log to console instead189 console.log(`${operation} failed: ${error.message}`);190 return of(result as T);191 };192 }193 private log(message: string) {194 console.log('productService: ' + message);195 }196 constructor(private http: HttpClient) { }...
txVerify.js
Source:txVerify.js
1import { isStringEqualCI } from '@/lib/textHelpers'2import i18n from '@/i18n'3const AllowAmountErrorPercent = 0.34const AllowTimestampDeltaSec = 1800 // 30 min5const TransactionInconsistentReason = {6 UNKNOWN: 'unknown',7 NO_RECIPIENT_CRYPTO_ADDRESS: 'no_recipient_crypto_address',8 NO_SENDER_CRYPTO_ADDRESS: 'no_sender_crypto_address',9 NO_RECIPIENT_ADM_ID: 'no_recipient_adm_id',10 NO_SENDER_ADM_ID: 'no_sender_adm_id',11 WRONG_TX_HASH: 'wrong_tx_hash',12 WRONG_AMOUNT: 'wrong_amount',13 WRONG_TIMESTAMP: 'wrong_timestamp',14 SENDER_CRYPTO_ADDRESS_MISMATCH: 'sender_crypto_address_mismatch',15 RECIPIENT_CRYPTO_ADDRESS_MISMATCH: 'recipient_crypto_address_mismatch'16}17export function verifyTransactionDetails (transaction, admSpecialMessage, { recipientCryptoAddress, senderCryptoAddress }) {18 try {19 const coin = admSpecialMessage.type20 if (!recipientCryptoAddress) {21 return {22 isTxConsistent: false,23 txCoin: coin,24 txInconsistentReason: TransactionInconsistentReason.NO_RECIPIENT_CRYPTO_ADDRESS25 }26 }27 if (!senderCryptoAddress) {28 return {29 isTxConsistent: false,30 txCoin: coin,31 txInconsistentReason: TransactionInconsistentReason.NO_SENDER_CRYPTO_ADDRESS32 }33 }34 if (!transaction.recipientId) {35 return {36 isTxConsistent: false,37 txCoin: coin,38 txInconsistentReason: TransactionInconsistentReason.NO_RECIPIENT_ADM_ID39 }40 }41 if (!transaction.senderId) {42 return {43 isTxConsistent: false,44 txCoin: coin,45 txInconsistentReason: TransactionInconsistentReason.NO_SENDER_ADM_ID46 }47 }48 if (!isStringEqualCI(transaction.hash, admSpecialMessage.hash)) {49 return {50 isTxConsistent: false,51 txCoin: coin,52 txInconsistentReason: TransactionInconsistentReason.WRONG_TX_HASH53 }54 }55 if (!verifyAmount(+transaction.amount, +admSpecialMessage.amount)) {56 return {57 isTxConsistent: false,58 txCoin: coin,59 txInconsistentReason: TransactionInconsistentReason.WRONG_AMOUNT60 }61 }62 // Don't check timestamp if there is no timestamp yet. F. e. transaction.instantsend = true for Dash63 if (transaction.timestamp && !verifyTimestamp(transaction.timestamp, admSpecialMessage.timestamp)) {64 return {65 isTxConsistent: false,66 txCoin: coin,67 txInconsistentReason: TransactionInconsistentReason.WRONG_TIMESTAMP68 }69 }70 if (!isStringEqualCI(transaction.senderId, senderCryptoAddress)) {71 return {72 isTxConsistent: false,73 txCoin: coin,74 txInconsistentReason: TransactionInconsistentReason.SENDER_CRYPTO_ADDRESS_MISMATCH75 }76 }77 if (!isStringEqualCI(transaction.recipientId, recipientCryptoAddress)) {78 return {79 isTxConsistent: false,80 txCoin: coin,81 txInconsistentReason: TransactionInconsistentReason.RECIPIENT_CRYPTO_ADDRESS_MISMATCH82 }83 }84 } catch (e) {85 return {86 isTxConsistent: false,87 txInconsistentReason: TransactionInconsistentReason.UNKNOWN88 }89 }90 return {91 isTxConsistent: true92 }93}94export function formatSendTxError (error) {95 const formattedError = {}96 formattedError.details = {}97 formattedError.details.status = error.response ? error.response.status : undefined98 formattedError.details.statusText = error.response ? error.response.statusText : undefined99 formattedError.details.error = error.toString()100 formattedError.details.response = error.response101 formattedError.errorMessage = `${i18n.t('error')}: `102 if (error.response && error.response.data) {103 const errorData = error.response.data104 if (errorData.error) {105 // Dash-like106 const codeString = errorData.error.code ? `[${errorData.error.code}]` : ''107 const messageString = errorData.error.message ? ` ${errorData.error.message}` : ''108 formattedError.errorCode = errorData.error.code109 formattedError.errorMessage += ` ${codeString}${messageString}`110 } else if (errorData.errors && errorData.errors[0]) {111 // Lisk-like112 formattedError.errorMessage += errorData.errors[0].message113 } else {114 // Unknown response format115 formattedError.errorMessage += typeof errorData === 'object' ? ` ${JSON.stringify(errorData, 0, 2)}` : errorData.toString()116 }117 } else {118 if (error.message) {119 // Doge-like120 formattedError.errorMessage += error.message121 } else {122 // Unknown123 formattedError.errorMessage += error.toString()124 }125 }126 return formattedError127}128/**129 * Delta should be <= AllowAmountErrorPercent130 */131function verifyAmount (transactionAmount, specialMessageAmount) {132 const margin = transactionAmount / (100 / AllowAmountErrorPercent)133 const delta = Math.abs(transactionAmount - specialMessageAmount)134 return delta <= margin135}136function verifyTimestamp (transactionTimestamp, specialMessageTimestamp) {137 const delta = Math.abs(transactionTimestamp - specialMessageTimestamp) / 1000138 return delta < AllowTimestampDeltaSec...
Using AI Code Generation
1var argosy = require('argosy')2var argosyPattern = require('argosy-pattern')3var argosyService = require('argosy-service')4var argosyServiceRegistry = require('argosy-service-registry')5var argosyServiceRegistryConsul = require('argosy-service-registry-consul')6var argosyServiceRegistryRedis = require('argosy-service-registry-redis')7var argosyServiceRegistryMemory = require('argosy-service-registry-memory')8var serviceRegistry = argosyServiceRegistry()9var serviceRegistry = argosyServiceRegistryConsul()10var serviceRegistry = argosyServiceRegistryRedis()11var serviceRegistry = argosyServiceRegistryMemory()12var service = argosyService()13var pattern = argosyPattern()14var argosy = argosy()15 .use(serviceRegistry)16 .use(service)17 .use(pattern)18var argosy = require('argosy')19var serviceRegistry = require('argosy-service-registry')20var service = require('argosy-service')21var pattern = require('argosy-pattern')22var argosy = argosy()23 .use(serviceRegistry())24 .use(service())25 .use(pattern())26var argosy = require('argosy')27var serviceRegistry = require('argosy-service-registry')28var service = require('argosy-service')29var pattern = require('argosy-pattern')30var argosy = argosy()31 .use(serviceRegistry())32 .use(service())33 .use(pattern())34var argosy = require('argosy')35var serviceRegistry = require('argosy-service-registry')36var service = require('argosy-service')37var pattern = require('argosy-pattern')38var argosy = argosy()39 .use(serviceRegistry())40 .use(service())41 .use(pattern())42var argosy = require('argosy')
Using AI Code Generation
1var argosy = require('argosy')2var argosyPattern = require('argosy-pattern')3var argosyService = require('argosy-service')4var argosyServiceRegistry = require('argosy-service-registry')5var argosyServiceLocator = require('argosy-service-locator')6var argosyServiceLocatorClient = require('argosy-service-locator-client')7var argosyServiceRegistryClient = require('argosy-service-registry-client')8var argosyServiceClient = require('argosy-service-client')9var argosyServiceRegistryClient = require(
Using AI Code Generation
1var argosy = require('argosy')2var argosyPattern = require('argosy-pattern')3var argosyService = require('argosy-service')4var argosyServiceRegistry = require('argosy-service-registry')5var argosyServiceRegistryClient = require('argosy-service-registry-client')6var argosyServiceRegistry = argosyServiceRegistry()7var argosyServiceRegistryClient = argosyServiceRegistryClient()8var argosy = argosy()9 .use(argosyPattern({10 }))11 .use(argosyServiceRegistry)12 .use(argosyServiceRegistryClient)13 .use(argosyService({14 }, function (msg, callback) {15 callback(null, 'test')16 }))17argosy.listen(8000)18var argosy = require('argosy')19var argosyPattern = require('argosy-pattern')20var argosyService = require('argosy-service')21var argosyServiceRegistry = require('argosy-service-registry')22var argosyServiceRegistryClient = require('argosy-service-registry-client')23var argosyServiceRegistry = argosyServiceRegistry()24var argosyServiceRegistryClient = argosyServiceRegistryClient()25var argosy = argosy()26 .use(argosyPattern({27 }))28 .use(argosyServiceRegistry)29 .use(argosyServiceRegistryClient)30 .use(argosyService({31 }, function (msg, callback) {32 callback(null, 'test')33 }))34argosy.listen(8000)35var argosy = require('argosy')36var argosyPattern = require('argosy-pattern')37var argosyService = require('argosy-service')38var argosyServiceRegistry = require('argosy-service-registry')39var argosyServiceRegistryClient = require('argosy-service-registry-client')40var argosyServiceRegistry = argosyServiceRegistry()
Using AI Code Generation
1var argosy = require('argosy')2var argosyPattern = require('argosy-pattern')3var argosyRpc = require('argosy-rpc')4var argosyRpcClient = require('argosy-rpc/client')5var argosyRpcServer = require('argosy-rpc/server')6var argosyPipe = require('argosy-pipe')7var argosyHttp = require('argosy-http')8var argosyWebsocket = require('argosy-websocket')9var argosyWebsocketClient = require('argosy-websocket/client')10var argosyWebsocketServer = require('argosy-websocket/server')11var argosyService = require('argosy-service')12var argosyServiceClient = require('argosy-service/client')13var argosyServiceServer = require('argosy-service/server')14var argosyServicePipe = require('argosy-service/pipe')15var argosyServiceHttp = require('argosy-service/http')16var argosyServiceWebsocket = require('argosy-service/websocket')17var argosyServiceWebsocketClient = require('argosy-service/websocket/client')18var argosyServiceWebsocketServer = require('argosy-service/websocket/server')19var argosyServiceWebsocketPipe = require('argosy-service/websocket/pipe')20var argosyServiceWebsocketHttp = require('argosy-service/websocket/http')21var argosyServiceWebsocketWebsocket = require('argosy-service/websocket/websocket')22var argosyServiceWebsocketWebsocketClient = require('argosy-service/websocket/websocket/client')23var argosyServiceWebsocketWebsocketServer = require('argosy-service/websocket/websocket/server')24var argosyServiceWebsocketWebsocketPipe = require('argosy-service/websocket/websocket/pipe')25var argosyServiceWebsocketWebsocketHttp = require('argosy-service/websocket/websocket/http')26var argosyServiceWebsocketWebsocketWebsocket = require('argosy-service/websocket/websocket/websocket')27var argosyServiceWebsocketWebsocketWebsocketClient = require('argosy-service/websocket/websocket/websocket/client')28var argosyServiceWebsocketWebsocketWebsocketServer = require('argos
Using AI Code Generation
1var argosy = require('argosy')2var argosyService = require('argosy-service')3var argosyPattern = require('argosy-pattern')4var argosyService = require('argosy-service')5var argosyService = require('argosy-service')6var service = argosy()7service.pipe(argosyService()).pipe(service)8service.accept({role: 'test', cmd: 'hello'}, function (msg, callback) {9 callback(null, {hello: msg.name})10})11var argosy = require('argosy')12var argosyService = require('argosy-service')13var argosyPattern = require('argosy-pattern')14var argosyService = require('argosy-service')15var argosyService = require('argosy-service')16var service = argosy()17service.pipe(argosyService()).pipe(service)18service.accept({role: 'test', cmd: 'hello'}, function (msg, callback) {19 callback(null, {hello: msg.name})20})21var argosy = require('argosy')22var argosyService = require('argosy-service')23var argosyPattern = require('argosy-pattern')24var argosyService = require('argosy-service')25var argosyService = require('argosy-service')26var service = argosy()27service.pipe(argosyService()).pipe(service)28service.accept({role: 'test', cmd: 'hello'}, function (msg, callback) {29 callback(null, {hello: msg.name})30})31var argosy = require('argosy')32var argosyService = require('argosy-service')33var argosyPattern = require('argosy-pattern')34var argosyService = require('argosy-service')35var argosyService = require('argosy-service')36var service = argosy()37service.pipe(argosyService()).pipe(service)38service.accept({role: 'test', cmd: 'hello'}, function (msg, callback) {39 callback(null, {hello
Using AI Code Generation
1var argosy = require('argosy')2var argosyPattern = require('argosy-pattern')3var argosyService = argosy()4var argosyServicePattern = argosyPattern()5argosyService.pipe(argosyServicePattern).pipe(argosyService)6argosyService.accept({role:'foo',cmd:'bar'}, function (msg, cb) {7 cb(null, {ok:true})8})9argosyService.accept(pattern({role:'foo',cmd:'bar'}), function (msg, cb) {10 cb(null, {ok:true})11})12var argosy = require('argosy')13var argosyPattern = require('argosy-pattern')14var argosyService = argosy()15var argosyServicePattern = argosyPattern()16argosyService.pipe(argosyServicePattern).pipe(argosyService)17argosyService.accept(pattern({role:'foo',cmd:'bar'}), function (msg, cb) {18 cb(null, {ok:true})19})20argosyService.accept({role:'foo',cmd:'bar'}, function (msg, cb) {21 cb(null, {ok:true})22})23var argosy = require('argosy')24var argosyPattern = require('argosy-pattern')25var argosyService = argosy()26var argosyServicePattern = argosyPattern()27argosyService.pipe(argosyServicePattern).pipe(argosyService)28argosyService.accept({role:'foo',cmd:'bar'}, function (msg, cb) {29 cb(null, {ok:true})
Using AI Code Generation
1var argosy = require('argosy')2var service = argosy()3service.pipe(argosy.acceptor({4}))5service.accept({6 greet: function (name, cb) {7 cb(null, 'hello ' + name)8 }9})10var argosy = require('argosy')11var service = argosy()12service.pipe(argosy.acceptor({13}))14service.accept({15 greet: function (name, cb) {16 cb(null, 'hello ' + name)17 }18})19var argosy = require('argosy')20var service = argosy()21service.pipe(argosy.acceptor({22}))23service.accept({24 greet: function (name, cb) {25 cb(null, 'hello ' + name)26 }27})28var argosy = require('argosy')29var service = argosy()30service.pipe(argosy.acceptor({31}))32service.accept({33 greet: function (name, cb) {34 cb(null, 'hello ' + name)35 }36})37var argosy = require('argosy')38var service = argosy()39service.pipe(argosy.acceptor({40}))41service.accept({42 greet: function (name, cb) {43 cb(null, 'hello ' + name)44 }45})46var argosy = require('argosy')47var service = argosy()48service.pipe(argosy.acceptor({49}))50service.accept({51 greet: function (name, cb) {52 cb(null, 'hello ' + name)53 }54})55var argosy = require('argosy')56var service = argosy()57service.pipe(argosy.acceptor({58}))
Using AI Code Generation
1var argosy = require('argosy')2var service = argosy()3service.pipe(service)4service.accept({role: 'math', cmd: 'sum'}, function (msg, cb) {5 cb(null, {answer: msg.left + msg.right})6})7service.accept({role: 'math', cmd: 'product'}, function (msg, cb) {8 cb(null, {answer: msg.left * msg.right})9})10service.accept({role: 'math', cmd: 'sum', integer: true}, function (msg, cb) {11 cb(null, {answer: Math.round(msg.left + msg.right)})12})13service.accept({role: 'math', cmd: 'product', integer: true}, function (msg, cb) {14 cb(null, {answer: Math.round(msg.left * msg.right)})15})16service.accept({role: 'math', cmd: 'sum', integer: true}, function (msg, cb) {17 cb(null, {answer: Math.floor(msg.left + msg.right)})18})19service.accept({role: 'math', cmd: 'product', integer: true}, function (msg, cb) {20 cb(null, {answer: Math.floor(msg.left * msg.right)})21})22service.accept({role: 'math', cmd: 'sum', integer: true}, function (msg, cb) {23 cb(null, {answer: Math.ceil(msg.left + msg.right)})24})25service.accept({role: 'math', cmd: 'product', integer: true}, function (msg, cb) {26 cb(null, {answer: Math.ceil(msg.left * msg.right)})27})28service.accept({role: 'math', cmd: 'sum', integer: true}, function (msg, cb) {29 cb(null, {answer: Math.trunc(msg.left + msg.right)})30})31service.accept({role: 'math', cmd: 'product', integer: true}, function (msg, cb) {32 cb(null, {answer: Math.trunc(msg.left * msg.right)})33})34service.accept({role: 'math', cmd: 'sum', integer: true}, function (msg, cb) {35 cb(null, {answer: Math.round(msg.left + msg.right)})36})37service.accept({role: 'math', cmd: 'product', integer: true}, function (msg, cb) {38 cb(null, {answer: Math.round(msg.left * msg
Using AI Code Generation
1var argos = require('argos');2var myArgos = new argos();3var myFunc = function(){4 console.log('hello world');5};6myArgos.on('someEvent', myFunc);7myArgos.emit('someEvent');8myArgos.removeListener('someEvent', myFunc);9myArgos.emit('someEvent');10var argos = require('argos');11var myArgos = new argos();12var myFunc = function(){13 console.log('hello world');14};15myArgos.on('someEvent', myFunc);16myArgos.emit('someEvent');17myArgos.off('someEvent', myFunc);18myArgos.emit('someEvent');19var argos = require('argos');20var myArgos = new argos();21var myFunc = function(){22 console.log('hello world');23};24myArgos.on('someEvent', myFunc);25myArgos.emit('someEvent');26myArgos.off('someEvent');27myArgos.emit('someEvent');28var argos = require('argos');29var myArgos = new argos();30var myFunc = function(){31 console.log('hello world');32};33myArgos.on('someEvent', myFunc);34myArgos.emit('someEvent');35myArgos.off();36myArgos.emit('someEvent');
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!