How to use updateExecution method in redwood

Best JavaScript code snippet using redwood

anchor_token_helper.ts

Source:anchor_token_helper.ts Github

copy

Full Screen

1import {2 BlockTxBroadcastResult,3 Coin,4 Coins,5 Dec,6 Int,7 isTxError,8 LCDClient,9 Msg,10 MsgExecuteContract,11 MsgInstantiateContract,12 MsgStoreCode,13 Fee,14 Wallet,15} from "@terra-money/terra.js";16import * as fs from "fs";17import { execute, instantiate, send_transaction } from "./flow/execution";18import { anchor } from "../ops/ops";19type PollStatus = "in_progress" | "passed" | "rejected" | "expired";20export type VoteOption = "yes" | "no";21export interface ExecuteMsg {22 contract: string;23 msg: string;24}25type Mint = {26 minter: string;27 cap?: number;28};29const contracts = [30 "gov",31 "faucet",32 "collector",33 "community",34 "staking",35 "token",36 "airdrop",37];38export default class AnchorToken {39 public contractInfo: {40 [contractName: string]: { codeId: number; contractAddress: string };41 };42 constructor() {43 this.contractInfo = {};44 }45 public async storeCodes(46 sender: Wallet,47 location: string,48 fee?: Fee49 ): Promise<void> {50 return contracts.reduce(51 (t, c) =>52 t.then(async () => {53 const bytecode = fs.readFileSync(`${location}/anchor_${c}.wasm`);54 const storeCode = new MsgStoreCode(55 sender.key.accAddress,56 bytecode.toString("base64")57 );58 const result = await send_transaction(sender, [storeCode], fee);59 if (isTxError(result)) {60 throw new Error(`Couldn't upload ${c}: ${result.raw_log}`);61 }62 const codeId = +result.logs[0].eventsByType.store_code.code_id[0];63 this.contractInfo[c] = {64 codeId,65 contractAddress: "",66 };67 }),68 Promise.resolve()69 );70 }71 public async gov_instantiate(72 sender: Wallet,73 params: {74 anchor_token?: string;75 quorum?: string;76 threshold?: string;77 voting_period?: number;78 timelock_period?: number;79 expiration_period?: number;80 proposal_deposit?: string;81 snapshot_period?: string;82 },83 fee?: Fee84 ): Promise<void> {85 let contract = this.contractInfo["gov"].codeId;86 let token = this.contractInfo["token"].contractAddress;87 const init = await instantiate(88 sender,89 contract,90 {91 anchor_token: token,92 owner: sender.key.accAddress,93 quorum: params.quorum || "0.1",94 threshold: params.threshold || "0.5",95 voting_period: params.voting_period || 10,96 timelock_period: params.timelock_period || 10,97 expiration_period: params.expiration_period || 10,98 proposal_deposit: params.proposal_deposit || "1000000",99 snapshot_period: params.snapshot_period || 5,100 },101 undefined,102 fee103 );104 if (isTxError(init)) {105 throw new Error(`Couldn't run: ${init.raw_log}`);106 }107 if (isTxError(init)) {108 throw new Error(109 `Couldn't upload ${this.contractInfo["gov"].codeId}: ${init.raw_log}`110 );111 }112 const govAddr =113 init.logs[0].eventsByType.instantiate_contract.contract_address[0];114 this.contractInfo["gov"].contractAddress = govAddr;115 console.log(116 `gov: { codeId: ${this.contractInfo.gov.codeId}, contractAddress: "${this.contractInfo.gov.contractAddress}"},`117 );118 }119 public async staking_instantiation(120 sender: Wallet,121 params: {122 anchor_token?: string;123 staking_token?: string;124 distribution_schedule?: [number, number, string][];125 },126 fee?: Fee127 ): Promise<void> {128 let contract = this.contractInfo["staking"].codeId;129 let token = this.contractInfo["token"].contractAddress;130 const init = await instantiate(131 sender,132 contract,133 {134 anchor_token: params.anchor_token || token,135 staking_token: params.staking_token,136 distribution_schedule: params.distribution_schedule || [137 [2690000, 3190000, "100000000000"],138 ],139 },140 undefined,141 fee142 );143 if (isTxError(init)) {144 throw new Error(`Couldn't run: ${init.raw_log}`);145 }146 if (isTxError(init)) {147 throw new Error(148 `Couldn't upload ${this.contractInfo["staking"].codeId}: ${init.raw_log}`149 );150 }151 const stakingAddr =152 init.logs[0].eventsByType.instantiate_contract.contract_address[0];153 this.contractInfo["staking"].contractAddress = stakingAddr;154 console.log(155 `staking: { codeId: ${this.contractInfo.staking.codeId}, contractAddress: "${this.contractInfo.staking.contractAddress}"},`156 );157 }158 public async community_instantiation(159 sender: Wallet,160 params: {161 gov_contract?: string;162 anchor_token?: string;163 spend_limit?: string;164 },165 fee?: Fee166 ): Promise<void> {167 let contract = this.contractInfo["community"].codeId;168 let gov = this.contractInfo["gov"].contractAddress;169 let token = this.contractInfo["token"].contractAddress;170 const init = await instantiate(171 sender,172 contract,173 {174 gov_contract: gov || params.gov_contract,175 anchor_token: token,176 spend_limit: params.spend_limit || "100000000000",177 },178 undefined,179 fee180 );181 if (isTxError(init)) {182 throw new Error(`Couldn't run: ${init.raw_log}`);183 }184 if (isTxError(init)) {185 throw new Error(186 `Couldn't upload ${this.contractInfo["community"].codeId}: ${init.raw_log}`187 );188 }189 const comunityAddr =190 init.logs[0].eventsByType.instantiate_contract.contract_address[0];191 this.contractInfo["community"].contractAddress = comunityAddr;192 console.log(193 `community: { codeId: ${this.contractInfo.community.codeId}, contractAddress: "${this.contractInfo.community.contractAddress}"},`194 );195 }196 public async collector_instantiation(197 sender: Wallet,198 params: {199 gov_contract?: string;200 terraswap_factory?: string;201 anchor_token?: string;202 faucet_contract?: string;203 reward_factor?: string;204 },205 fee?: Fee206 ): Promise<void> {207 let contract = this.contractInfo["collector"].codeId;208 let gov = this.contractInfo["gov"].contractAddress;209 let token = this.contractInfo["token"].contractAddress;210 let faucet = this.contractInfo["token"].contractAddress;211 const init = await instantiate(212 sender,213 contract,214 {215 gov_contract: gov,216 terraswap_factory: params.terraswap_factory,217 anchor_token: token,218 faucet_contract: faucet,219 reward_factor: params.reward_factor || "0.5",220 },221 undefined,222 fee223 );224 if (isTxError(init)) {225 throw new Error(`Couldn't run: ${init.raw_log}`);226 }227 if (isTxError(init)) {228 throw new Error(229 `Couldn't upload ${this.contractInfo["collector"].codeId}: ${init.raw_log}`230 );231 }232 const collectorAddr =233 init.logs[0].eventsByType.instantiate_contract.contract_address[0];234 this.contractInfo["collector"].contractAddress = collectorAddr;235 console.log(236 `collector: { codeId: ${this.contractInfo.collector.codeId}, contractAddress: "${this.contractInfo.collector.contractAddress}"},`237 );238 }239 public async faucet_instantiation(240 sender: Wallet,241 params: {242 gov_contract?: string;243 anchor_token?: string;244 whitelist?: string[];245 spend_limit?: string;246 },247 fee?: Fee248 ): Promise<void> {249 let contract = this.contractInfo["faucet"].codeId;250 let gov = this.contractInfo["gov"].contractAddress;251 let token = this.contractInfo["token"].contractAddress;252 const init = await instantiate(253 sender,254 contract,255 {256 gov_contract: gov,257 anchor_token: token,258 whitelist: params.whitelist,259 spend_limit: params.spend_limit || "100000000000",260 },261 undefined,262 fee263 );264 if (isTxError(init)) {265 throw new Error(`Couldn't run: ${init.raw_log}`);266 }267 if (isTxError(init)) {268 throw new Error(269 `Couldn't upload ${this.contractInfo["faucet"].codeId}: ${init.raw_log}`270 );271 }272 const faucetAddr =273 init.logs[0].eventsByType.instantiate_contract.contract_address[0];274 this.contractInfo["faucet"].contractAddress = faucetAddr;275 console.log(276 `faucet: { codeId: ${this.contractInfo.faucet.codeId}, contractAddress: "${this.contractInfo.faucet.contractAddress}"},`277 );278 }279 public async airdrop_instantiation(280 sender: Wallet,281 params: {282 owner?: string;283 anchor_token?: string;284 },285 fee?: Fee286 ): Promise<void> {287 let contract = this.contractInfo["airdrop"].codeId;288 const init = await instantiate(289 sender,290 contract,291 {292 owner: params.owner || sender.key.accAddress,293 anchor_token:294 params.anchor_token || this.contractInfo.token.contractAddress,295 },296 undefined,297 fee298 );299 if (isTxError(init)) {300 throw new Error(`Couldn't run: ${init.raw_log}`);301 }302 if (isTxError(init)) {303 throw new Error(304 `Couldn't upload ${this.contractInfo["airdrop"].codeId}: ${init.raw_log}`305 );306 }307 const airdropAddr =308 init.logs[0].eventsByType.instantiate_contract.contract_address[0];309 this.contractInfo["airdrop"].contractAddress = airdropAddr;310 console.log(311 `airdrop: { codeId: ${this.contractInfo.airdrop.codeId}, contractAddress: "${this.contractInfo.airdrop.contractAddress}"},`312 );313 }314 public async instantiate_token(315 sender: Wallet,316 params: {317 name?: string;318 symbol?: string;319 decimals?: number;320 initial_balances?: object;321 mint?: Mint;322 },323 fee?: Fee324 ): Promise<void> {325 const init = await instantiate(326 sender,327 this.contractInfo.token.codeId,328 {329 name: params.name || "Test Token",330 symbol: params.symbol || "TTN",331 decimals: params.decimals || 6,332 initial_balances: params.initial_balances || [333 {334 address: sender.key.accAddress,335 amount: "1000000000000",336 },337 ],338 mint: undefined,339 init_hook: undefined,340 },341 undefined,342 fee343 );344 if (isTxError(init)) {345 throw new Error(`Couldn't instantiate: ${init.raw_log}`);346 }347 const contractAddress =348 init.logs[0].eventsByType.instantiate_contract.contract_address[0];349 this.contractInfo.token.contractAddress = contractAddress;350 console.log(351 `anchor_token: { codeId: ${this.contractInfo.token.codeId}, contractAddress: "${this.contractInfo.token.contractAddress}"},`352 );353 }354 public async collector_sweep(355 sender: Wallet,356 params: {357 denom: string;358 }359 ): Promise<void> {360 let contract = this.contractInfo["collector"].contractAddress;361 const updateExecution = await execute(sender, contract, {362 sweep: {363 denom: params.denom,364 },365 });366 if (isTxError(updateExecution)) {367 throw new Error(`Couldn't run: ${updateExecution.raw_log}`);368 }369 }370 public async collector_update_config(371 sender: Wallet,372 params: {373 reward_weight?: string;374 }375 ): Promise<void> {376 let contract = this.contractInfo["collector"].contractAddress;377 const updateExecution = await execute(sender, contract, {378 update_config: {379 denom: params.reward_weight,380 },381 });382 if (isTxError(updateExecution)) {383 throw new Error(`Couldn't run: ${updateExecution.raw_log}`);384 }385 }386 public async community_spend(387 sender: Wallet,388 params: {389 recipient: string;390 amount: string;391 }392 ): Promise<void> {393 let contract = this.contractInfo["community"].contractAddress;394 const updateExecution = await execute(sender, contract, {395 spend: {396 recipient: params.recipient,397 amount: new Int(new Dec(params.amount).mul(1000000)).toString(),398 },399 });400 if (isTxError(updateExecution)) {401 throw new Error(`Couldn't run: ${updateExecution.raw_log}`);402 }403 }404 public async community_update_config(405 sender: Wallet,406 params: {407 spend_limit?: string;408 }409 ): Promise<void> {410 let contract = this.contractInfo["community"].contractAddress;411 const updateExecution = await execute(sender, contract, {412 update_config: {413 spend_limit: params.spend_limit,414 },415 });416 if (isTxError(updateExecution)) {417 throw new Error(`Couldn't run: ${updateExecution.raw_log}`);418 }419 }420 public async faucet_spend(421 sender: Wallet,422 params: {423 recipient: string;424 amount: string;425 }426 ): Promise<void> {427 let contract = this.contractInfo["faucet"].contractAddress;428 const updateExecution = await execute(sender, contract, {429 spend: {430 recipient: params.recipient,431 amount: new Int(new Dec(params.amount).mul(1000000)).toString(),432 },433 });434 if (isTxError(updateExecution)) {435 throw new Error(`Couldn't run: ${updateExecution.raw_log}`);436 }437 }438 public async faucet_update_config(439 sender: Wallet,440 params: {441 spend_limit?: string;442 }443 ): Promise<void> {444 let contract = this.contractInfo["faucet"].contractAddress;445 const updateExecution = await execute(sender, contract, {446 update_config: {447 spend_limit: params.spend_limit,448 },449 });450 if (isTxError(updateExecution)) {451 throw new Error(`Couldn't run: ${updateExecution.raw_log}`);452 }453 }454 public async gov_cast_vote(455 sender: Wallet,456 params: {457 poll_id: number;458 vote: VoteOption;459 amount: string;460 }461 ): Promise<void> {462 let contract = this.contractInfo["gov"].contractAddress;463 const updateExecution = await execute(sender, contract, {464 cast_vote: {465 poll_id: params.poll_id,466 vote: params.vote,467 amount: new Int(new Dec(params.amount).mul(1000000)).toString(),468 },469 });470 if (isTxError(updateExecution)) {471 throw new Error(`Couldn't run: ${updateExecution.raw_log}`);472 }473 }474 public async gov_create_poll(475 sender: Wallet,476 params: {477 amount: string;478 title: string;479 description: string;480 link?: string;481 execute_msg?: ExecuteMsg;482 }483 ): Promise<void> {484 let contract = this.contractInfo["token"].contractAddress;485 const updateExecution = await execute(sender, contract, {486 send: {487 contract: this.contractInfo["gov"].contractAddress,488 amount: new Int(new Dec(params.amount).mul(1000000)).toString(),489 msg: Buffer.from(490 JSON.stringify({491 create_poll: {492 title: params.title,493 description: params.description,494 link: params.link,495 execute_msg: params.execute_msg,496 },497 })498 ).toString("base64"),499 },500 });501 if (isTxError(updateExecution)) {502 throw new Error(`Couldn't run: ${updateExecution.raw_log}`);503 }504 }505 public async gov_stake_voting(506 sender: Wallet,507 params: {508 amount: string;509 }510 ): Promise<void> {511 let contract = this.contractInfo["token"].contractAddress;512 const updateExecution = await execute(sender, contract, {513 send: {514 contract: this.contractInfo["gov"].contractAddress,515 amount: new Int(new Dec(params.amount).mul(1000000)).toString(),516 msg: Buffer.from(517 JSON.stringify({518 stake_voting_tokens: {},519 })520 ).toString("base64"),521 },522 });523 if (isTxError(updateExecution)) {524 throw new Error(`Couldn't run: ${updateExecution.raw_log}`);525 }526 }527 public async gov_end_poll(528 sender: Wallet,529 params: {530 poll_id: number;531 }532 ): Promise<void> {533 let contract = this.contractInfo["gov"].contractAddress;534 const updateExecution = await execute(sender, contract, {535 end_poll: {536 poll_id: params.poll_id,537 },538 });539 if (isTxError(updateExecution)) {540 throw new Error(`Couldn't run: ${updateExecution.raw_log}`);541 }542 }543 public async gov_execute_poll(544 sender: Wallet,545 params: {546 poll_id: number;547 }548 ): Promise<void> {549 let contract = this.contractInfo["gov"].contractAddress;550 const updateExecution = await execute(sender, contract, {551 execute_poll: {552 poll_id: params.poll_id,553 },554 });555 if (isTxError(updateExecution)) {556 throw new Error(`Couldn't run: ${updateExecution.raw_log}`);557 }558 }559 public async gov_expire_poll(560 sender: Wallet,561 params: {562 poll_id: number;563 }564 ): Promise<void> {565 let contract = this.contractInfo["gov"].contractAddress;566 const updateExecution = await execute(sender, contract, {567 expire_poll: {568 poll_id: params.poll_id,569 },570 });571 if (isTxError(updateExecution)) {572 throw new Error(`Couldn't run: ${updateExecution.raw_log}`);573 }574 }575 public async gov_snapshot_poll(576 sender: Wallet,577 params: {578 poll_id: number;579 }580 ): Promise<void> {581 let contract = this.contractInfo["gov"].contractAddress;582 const updateExecution = await execute(sender, contract, {583 snapshot_poll: {584 poll_id: params.poll_id,585 },586 });587 if (isTxError(updateExecution)) {588 throw new Error(`Couldn't run: ${updateExecution.raw_log}`);589 }590 }591 public async gov_withdraw_voting(592 sender: Wallet,593 params: {594 amount: string;595 }596 ): Promise<void> {597 let contract = this.contractInfo["gov"].contractAddress;598 const updateExecution = await execute(sender, contract, {599 withdraw_voting_tokens: {600 amount: new Int(new Dec(params.amount).mul(1000000)).toString(),601 },602 });603 if (isTxError(updateExecution)) {604 throw new Error(`Couldn't run: ${updateExecution.raw_log}`);605 }606 }607 public async gov_update_config(608 sender: Wallet,609 params: {610 owner?: string;611 quorum?: string;612 threshold?: string;613 voting_period?: number;614 timelock_period?: number;615 expiration_period?: number;616 proposal_deposit?: string;617 snapshot_period?: string;618 }619 ): Promise<void> {620 let contract = this.contractInfo["gov"].contractAddress;621 const updateExecution = await execute(sender, contract, {622 update_config: {623 owner: params.owner,624 quorum: params.quorum,625 threshold: params.threshold,626 voting_period: params.voting_period,627 timelock_period: params.timelock_period,628 expiration_period: params.expiration_period,629 proposal_deposit: params.proposal_deposit,630 snapshot_period: params.snapshot_period,631 },632 });633 if (isTxError(updateExecution)) {634 throw new Error(`Couldn't run: ${updateExecution.raw_log}`);635 }636 }637 public async staking_bond(638 sender: Wallet,639 params: {640 amount: string;641 }642 ): Promise<void> {643 let contract = this.contractInfo["token"].contractAddress;644 const updateExecution = await execute(sender, contract, {645 send: {646 contract: this.contractInfo["staking"].contractAddress,647 amount: new Int(new Dec(params.amount).mul(1000000)).toString(),648 msg: Buffer.from(649 JSON.stringify({650 bond: {},651 })652 ).toString("base64"),653 },654 });655 if (isTxError(updateExecution)) {656 throw new Error(`Couldn't run: ${updateExecution.raw_log}`);657 }658 }659 public async staking_deposit(660 sender: Wallet,661 params: {662 amount: string;663 }664 ): Promise<void> {665 let contract = this.contractInfo["token"].contractAddress;666 const updateExecution = await execute(sender, contract, {667 send: {668 contract: this.contractInfo["staking"].contractAddress,669 amount: new Int(new Dec(params.amount).mul(1000000)).toString(),670 msg: Buffer.from(671 JSON.stringify({672 deposit_reward: {},673 })674 ).toString("base64"),675 },676 });677 if (isTxError(updateExecution)) {678 throw new Error(`Couldn't run: ${updateExecution.raw_log}`);679 }680 }681 public async staking_unbond(682 sender: Wallet,683 params: {684 amount: string;685 }686 ): Promise<void> {687 let contract = this.contractInfo["staking"].contractAddress;688 const updateExecution = await execute(sender, contract, {689 unbond: {690 amount: new Int(new Dec(params.amount).mul(1000000)).toString(),691 },692 });693 if (isTxError(updateExecution)) {694 throw new Error(`Couldn't run: ${updateExecution.raw_log}`);695 }696 }697 public async staking_withdraw(sender: Wallet, params: {}): Promise<void> {698 let contract = this.contractInfo["staking"].contractAddress;699 const updateExecution = await execute(sender, contract, { withdraw: {} });700 if (isTxError(updateExecution)) {701 throw new Error(`Couldn't run: ${updateExecution.raw_log}`);702 }703 }704 public async transfer_cw20_token(705 sender: Wallet,706 rcv: string,707 amount: number708 ): Promise<void> {709 const contract = this.contractInfo.token.contractAddress;710 const transferExecuttion = await execute(sender, contract, {711 transfer: {712 recipient: rcv,713 amount: `${amount}`,714 },715 });716 if (isTxError(transferExecuttion)) {717 throw new Error(`Couldn't run: ${transferExecuttion.raw_log}`);718 }719 }720 public async get_anc_balance(sender: Wallet, address: string): Promise<any> {721 let response = await sender.lcd.wasm.contractQuery(722 this.contractInfo["token"].contractAddress,723 {724 balance: {725 address: address,726 },727 }728 );729 return response;730 }731 public async get_gov_state(sender: Wallet): Promise<any> {732 let response = await sender.lcd.wasm.contractQuery(733 this.contractInfo["gov"].contractAddress,734 {735 state: {},736 }737 );738 return response;739 }740 public async get_gov_staker(sender: Wallet, address: string): Promise<any> {741 let response = await sender.lcd.wasm.contractQuery(742 this.contractInfo["gov"].contractAddress,743 {744 staker: {745 address: address,746 },747 }748 );749 return response;750 }751 public async get_gov_polls(752 sender: Wallet,753 filter: PollStatus,754 startAfter?: number,755 limit?: number756 ): Promise<any> {757 let response = await sender.lcd.wasm.contractQuery(758 this.contractInfo["gov"].contractAddress,759 {760 polls: {761 filter: filter,762 start_after: startAfter,763 limit: limit,764 order_by: "asc",765 },766 }767 );768 return response;769 }770 public async get_staking_state(771 sender: Wallet,772 blockHeight: number773 ): Promise<any> {774 let response = await sender.lcd.wasm.contractQuery(775 this.contractInfo["staking"].contractAddress,776 {777 state: {778 block_height: blockHeight,779 },780 }781 );782 return response;783 }784 public async get_staking_staker_info(785 sender: Wallet,786 blockHeight: number,787 staker: string788 ): Promise<any> {789 let response = await sender.lcd.wasm.contractQuery(790 this.contractInfo["staking"].contractAddress,791 {792 staker_info: {793 staker: staker,794 block_height: blockHeight,795 },796 }797 );798 return response;799 }...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

...21// ----------------------------------------------------------------------------22// Example code23// ----------------------------------------------------------------------------24const pipelineExecution = [0, 0, 0, 0];25function updateExecution(filterIdx) {26 pipelineExecution[filterIdx]++;27 pipelineExecution.forEach((value, index) => {28 const el = document.querySelector(`.filter${index}`);29 if (el) {30 el.innerHTML = `Execution #${value}`;31 }32 });33}34const coneSource = vtkConeSource.newInstance({ height: 1.0 });35const filterA = vtkCalculator.newInstance();36const filterB = vtkCalculator.newInstance();37const filterC = vtkCalculator.newInstance();38filterA.setFormula({39 getArrays: (inputDataSets) => ({40 input: [],41 output: [42 {43 location: FieldDataTypes.CELL,44 name: 'a',45 dataType: 'Float32Array',46 attribute: AttributeTypes.SCALARS,47 },48 ],49 }),50 evaluate: (arraysIn, arraysOut) => {51 updateExecution(0);52 const [scalars] = arraysOut.map((d) => d.getData());53 for (let i = 0; i < scalars.length; i++) {54 scalars[i] = Math.random();55 }56 },57});58filterB.setFormula({59 getArrays: (inputDataSets) => ({60 input: [],61 output: [62 {63 location: FieldDataTypes.CELL,64 name: 'b',65 dataType: 'Float32Array',66 attribute: AttributeTypes.SCALARS,67 },68 ],69 }),70 evaluate: (arraysIn, arraysOut) => {71 updateExecution(1);72 const [scalars] = arraysOut.map((d) => d.getData());73 for (let i = 0; i < scalars.length; i++) {74 scalars[i] = Math.random();75 }76 },77});78const randFilter = macro.newInstance((publicAPI, model) => {79 macro.obj(publicAPI, model); // make it an object80 macro.algo(publicAPI, model, 1, 1); // mixin algorithm code 1 in, 1 out81 publicAPI.requestData = (inData, outData) => {82 // implement requestData83 updateExecution(2);84 const newArray = new Float32Array(85 inData[0].getPoints().getNumberOfPoints()86 );87 for (let i = 0; i < newArray.length; i++) {88 newArray[i] = i % 2 ? 1 : 0;89 }90 const da = vtkDataArray.newInstance({ name: 'spike', values: newArray });91 const newDataSet = vtk({ vtkClass: inData[0].getClassName() });92 newDataSet.shallowCopy(inData[0]);93 newDataSet.getPointData().setScalars(da);94 outData[0] = newDataSet;95 };96})();97filterC.setFormula({98 getArrays: (inputDataSets) => ({99 input: [],100 output: [101 {102 location: FieldDataTypes.CELL,103 name: 'c',104 dataType: 'Float32Array',105 attribute: AttributeTypes.SCALARS,106 },107 ],108 }),109 evaluate: (arraysIn, arraysOut) => {110 updateExecution(3);111 const [scalars] = arraysOut.map((d) => d.getData());112 for (let i = 0; i < scalars.length; i++) {113 scalars[i] = Math.random();114 }115 },116});117filterA.setInputConnection(coneSource.getOutputPort());118filterB.setInputConnection(filterA.getOutputPort());119randFilter.setInputConnection(filterB.getOutputPort());120filterC.setInputConnection(randFilter.getOutputPort());121const mapper = vtkMapper.newInstance();122mapper.setInputConnection(filterC.getOutputPort());123const actor = vtkActor.newInstance();124actor.setMapper(mapper);125renderer.addActor(actor);126renderer.resetCamera();127renderWindow.render();128// -----------------------------------------------------------129// UI control handling130// -----------------------------------------------------------131fullScreenRenderer.addController(controlPanel);132const representationSelector = document.querySelector('.representations');133const resolutionChange = document.querySelector('.resolution');134representationSelector.addEventListener('change', (e) => {135 const newRepValue = Number(e.target.value);136 actor.getProperty().setRepresentation(newRepValue);137 renderWindow.render();138});139resolutionChange.addEventListener('input', (e) => {140 const resolution = Number(e.target.value);141 coneSource.setResolution(resolution);142 renderWindow.render();143});144const buttons = document.querySelectorAll('button');145for (let i = 0; i < buttons.length; i++) {146 buttons[i].addEventListener('click', (e) => {147 const idx = Number(e.target.name);148 if (!Number.isNaN(idx)) {149 const filter = global.filters[idx];150 filter.modified();151 renderWindow.render();152 } else {153 // Reset154 pipelineExecution.forEach((v, index) => {155 pipelineExecution[index] = 0;156 });157 updateExecution(-1);158 }159 });160}161// Update UI162updateExecution(-1);163// -----------------------------------------------------------164// Make some variables global so that you can inspect and165// modify objects in your browser's developer console:166// -----------------------------------------------------------167global.source = coneSource;168global.filters = [filterA, filterB, randFilter, filterC];169global.mapper = mapper;170global.actor = actor;171global.renderer = renderer;...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { createGraphQLHandler, makeMergedSchema, makeServices } = require('@redwoodjs/api')2const schemas = require('src/graphql/**/*.{js,ts}')3const services = makeServices({ services: require('src/services/**/*.{js,ts}') })4const db = require('src/lib/db')5const handler = createGraphQLHandler({6 schema: makeMergedSchema({7 }),8 context: () => {9 return {10 currentUser: {},11 }12 },13})14module.exports.handler = async (event, context) => {15 const body = JSON.parse(event.body)16 const { id, status, result } = body17 const input = { id, status, result }18 const data = await handler(event, context)19 console.log('data', data)20 return {21 body: JSON.stringify({ data: data }),22 }23}

Full Screen

Using AI Code Generation

copy

Full Screen

1var redwood = require('redwood-client');2var client = new redwood.Client();3client.updateExecution('myExecutionId', 'myStatus', 'myMessage', 'myData', function(err, res) {4 if (err) {5 console.log('Error: ' + err);6 }7 console.log(res);8});9This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details

Full Screen

Using AI Code Generation

copy

Full Screen

1var redwood = require('./redwood-client');2var config = require('./config');3var executionId = "executionId";4var executionStatus = "executionStatus";5var executionResult = "executionResult";6var updateExecution = function(executionId, executionStatus, executionResult) {7 var redwoodUrl = config.redwoodUrl;8 var redwoodUser = config.redwoodUser;9 var redwoodPassword = config.redwoodPassword;10 var redwoodProjectName = config.redwoodProjectName;11 var redwoodProjectVersion = config.redwoodProjectVersion;12 var redwoodExecutionName = config.redwoodExecutionName;13 var redwoodExecutionVersion = config.redwoodExecutionVersion;14 var redwoodClient = new redwood.RedwoodClient(redwoodUrl, redwoodUser, redwoodPassword);15 var redwoodExecution = new redwood.RedwoodExecution(redwoodClient, redwoodProjectName, redwoodProjectVersion, redwoodExecutionName, redwoodExecutionVersion);16 redwoodExecution.updateExecution(executionId, executionStatus, executionResult, function(err, data) {17 if (err) {18 console.log(err);19 } else {20 console.log(data);21 }22 });23}24updateExecution(executionId, executionStatus, executionResult);

Full Screen

Using AI Code Generation

copy

Full Screen

1var Redwood = require('redwood');2var redwood = new Redwood();3var data = {4 "execution": {5 }6};7redwood.updateExecution(data, function (err, res) {8 if (err) {9 console.log(err);10 } else {11 console.log(res);12 }13});14var Redwood = require('redwood');15var redwood = new Redwood();16var data = {17 "execution": {18 }19};20redwood.getExecution(data, function (err, res) {21 if (err) {22 console.log(err);23 } else {24 console.log(res);25 }26});27var Redwood = require('redwood');28var redwood = new Redwood();29var data = {30 "execution": {31 }32};33redwood.deleteExecution(data, function (err, res) {34 if (err) {35 console.log(err);36 } else {37 console.log(res);38 }39});40var Redwood = require('redwood');41var redwood = new Redwood();42var data = {43 "test_run": {

Full Screen

Using AI Code Generation

copy

Full Screen

1const { redwood } = require('@redwoodjs/api')2const { db } = require('@redwoodjs/db')3const updateExecution = async (id, input) => {4 return await db.execution.update({ where: { id }, data: input })5}6const handler = async (event, context) => {7 const input = {8 }9 const result = await updateExecution(executionId, input)10 return {11 body: JSON.stringify({ data: result }),12 }13}14module.exports = { handler }

Full Screen

Using AI Code Generation

copy

Full Screen

1const RedwoodHQ = require('redwoodhq');2const redwood = new RedwoodHQ();3redwood.updateExecution('<project-id>', '<execution-id>', '<test-id>', '<status>', '<comment>', '<execution-name>', '<execution-description>', '<execution-start-date>', '<execution-end-date>', '<execution-status>', '<execution-comment>')4.then((res) => {5 console.log(res);6})7.catch((err) => {8 console.log(err);9});10const RedwoodHQ = require('redwoodhq');11const redwood = new RedwoodHQ();12redwood.updateTest('<project-id>', '<test-id>', '<test-name>', '<test-description>', '<test-type>', '<test-status>', '<test-comment>')13.then((res) => {14 console.log(res);15})16.catch((err) => {17 console.log(err);18});19const RedwoodHQ = require('redwoodhq');20const redwood = new RedwoodHQ();

Full Screen

Using AI Code Generation

copy

Full Screen

1var redwood = require('redwoodhq');2var executionId = '5c4d4e4f-4f4c-4e4c-4d4c-4e4c4d4e4f4c';3var status = 'failed';4var comment = 'execution failed due to some error';5client.updateExecution(executionId, status, comment).then((result) => {6 console.log(result);7}).catch((error) => {8 console.log(error);9});

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run redwood automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful