1- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2- // @ts -nocheck
31import { Wallet , JsonRpcProvider , ethers , Contract } from 'ethers' ;
42import {
5- Web3SignerProvider ,
6- Web3TelegramConfigOptions ,
3+ type Web3TelegramConfigOptions ,
4+ type Web3SignerProvider ,
75} from '../src/web3telegram/types.js' ;
86import { IExec , utils } from 'iexec' ;
97import { randomInt } from 'crypto' ;
108import { getSignerFromPrivateKey } from 'iexec/utils' ;
119
12- export const TEST_CHAIN = {
13- rpcURL : process . env . DRONE
14- ? 'http://bellecour-fork:8545'
15- : 'http://127.0.0.1:8545' ,
10+ const TEST_CHAIN = {
11+ rpcURL : 'http://localhost:8545' ,
1612 chainId : '134' ,
17- smsURL : process . env . DRONE ? 'http://sms:13300' : 'http://127.0.0.1:13300' ,
18- resultProxyURL : process . env . DRONE
19- ? 'http://result-proxy:13200'
20- : 'http://127.0.0.1:13200' ,
21- iexecGatewayURL : process . env . DRONE
22- ? 'http://market-api:3000'
23- : 'http://127.0.0.1:3000' ,
13+ smsURL : 'http://127.0.0.1:13300' ,
14+ smsDebugURL : 'http://127.0.0.1:13301' ,
15+ resultProxyURL : 'http://127.0.0.1:13200' ,
16+ iexecGatewayURL : 'http://127.0.0.1:3000' ,
2417 voucherHubAddress : '0x3137B6DF4f36D338b82260eDBB2E7bab034AFEda' ,
2518 voucherManagerWallet : new Wallet (
2619 '0x2c906d4022cace2b3ee6c8b596564c26c4dcadddf1e949b769bcb0ad75c40c33'
2720 ) ,
28- voucherSubgraphURL : process . env . DRONE
29- ? 'http://graphnode:8000/subgraphs/name/bellecour/iexec-voucher'
30- : 'http://127.0.0.1:8000/subgraphs/name/bellecour/iexec-voucher' ,
21+ voucherSubgraphURL :
22+ 'http://127.0.0.1:8000/subgraphs/name/bellecour/iexec-voucher' ,
3123 learnProdWorkerpool : 'prod-v8-learn.main.pools.iexec.eth' ,
3224 learnProdWorkerpoolOwnerWallet : new Wallet (
3325 '0x800e01919eadf36f110f733decb1cc0f82e7941a748e89d7a3f76157f6654bb3'
@@ -39,13 +31,9 @@ export const TEST_CHAIN = {
3931 appOwnerWallet : new Wallet (
4032 '0xa911b93e50f57c156da0b8bff2277d241bcdb9345221a3e246a99c6e7cedcde5'
4133 ) ,
42- provider : new JsonRpcProvider (
43- process . env . DRONE ? 'http://bellecour-fork:8545' : 'http://127.0.0.1:8545' ,
44- undefined ,
45- {
46- pollingInterval : 1000 , // speed up tests
47- }
48- ) ,
34+ provider : new JsonRpcProvider ( 'http://localhost:8545' , undefined , {
35+ pollingInterval : 1000 , // speed up tests
36+ } ) ,
4937 hubAddress : '0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f' ,
5038} ;
5139
@@ -80,27 +68,28 @@ export const getTestWeb3SignerProvider = (
8068) : Web3SignerProvider =>
8169 utils . getSignerFromPrivateKey ( TEST_CHAIN . rpcURL , privateKey ) ;
8270
71+ export const getTestRpcProvider = ( ) => new JsonRpcProvider ( TEST_CHAIN . rpcURL ) ;
72+
8373export const getTestIExecOption = ( ) => ( {
8474 smsURL : TEST_CHAIN . smsURL ,
75+ smsDebugURL : TEST_CHAIN . smsDebugURL ,
8576 resultProxyURL : TEST_CHAIN . resultProxyURL ,
8677 iexecGatewayURL : TEST_CHAIN . iexecGatewayURL ,
8778 voucherHubAddress : TEST_CHAIN . voucherHubAddress ,
8879 voucherSubgraphURL : TEST_CHAIN . voucherSubgraphURL ,
8980} ) ;
9081
9182export const getTestConfig = (
92- privateKey : string
83+ privateKey ? : string
9384) : [ Web3SignerProvider , Web3TelegramConfigOptions ] => {
94- const ethProvider = getTestWeb3SignerProvider ( privateKey ) ;
85+ const ethProvider = privateKey
86+ ? getTestWeb3SignerProvider ( privateKey )
87+ : undefined ;
9588 const options = {
9689 iexecOptions : getTestIExecOption ( ) ,
97- ipfsGateway : process . env . DRONE
98- ? 'http://ipfs:8080'
99- : 'http://127.0.0.1:8080' ,
100- ipfsNode : process . env . DRONE ? 'http://ipfs:5001' : 'http://127.0.0.1:5001' ,
101- dataProtectorSubgraph : process . env . DRONE
102- ? 'http://graphnode:8000/subgraphs/name/DataProtector-v2'
103- : 'http://127.0.0.1:8000/subgraphs/name/DataProtector-v2' ,
90+ ipfsGateway : 'http://127.0.0.1:8080' ,
91+ ipfsNode : 'http://127.0.0.1:5001' ,
92+ subgraphUrl : 'http://127.0.0.1:8000/subgraphs/name/bellecour/web3telegram' ,
10493 } ;
10594 return [ ethProvider , options ] ;
10695} ;
@@ -231,7 +220,7 @@ export const createVoucherType = async ({
231220 TEST_CHAIN . voucherHubAddress ,
232221 VOUCHER_HUB_ABI ,
233222 TEST_CHAIN . provider
234- ) ;
223+ ) as any ;
235224 const signer = TEST_CHAIN . voucherManagerWallet . connect ( TEST_CHAIN . provider ) ;
236225 const createVoucherTypeTxHash = await voucherHubContract
237226 . connect ( signer )
@@ -380,7 +369,7 @@ export const createVoucher = async ({
380369 TEST_CHAIN . voucherHubAddress ,
381370 VOUCHER_HUB_ABI ,
382371 TEST_CHAIN . provider
383- ) ;
372+ ) as any ;
384373
385374 const signer = TEST_CHAIN . voucherManagerWallet . connect ( TEST_CHAIN . provider ) ;
386375
@@ -397,7 +386,9 @@ export const createVoucher = async ({
397386
398387 if ( ! skipOrders ) {
399388 try {
400- const workerpoolprice = Math . floor ( value / WORKERPOOL_ORDER_PER_VOUCHER ) ;
389+ const workerpoolprice = Math . floor (
390+ Number ( value ) / WORKERPOOL_ORDER_PER_VOUCHER
391+ ) ;
401392 await createAndPublishWorkerpoolOrder (
402393 TEST_CHAIN . prodWorkerpool ,
403394 TEST_CHAIN . prodWorkerpoolOwnerWallet ,
@@ -412,7 +403,7 @@ export const createVoucher = async ({
412403 }
413404
414405 try {
415- return await voucherHubContract . getVoucher ( owner ) ;
406+ return voucherHubContract . getVoucher ( owner ) ;
416407 } catch ( error ) {
417408 console . error ( 'Error getting voucher:' , error ) ;
418409 throw error ;
@@ -439,7 +430,7 @@ export const addVoucherEligibleAsset = async (assetAddress, voucherTypeId) => {
439430 stateMutability : 'nonpayable' ,
440431 type : 'function' ,
441432 } ,
442- ] ) ;
433+ ] ) as any ;
443434
444435 const signer = TEST_CHAIN . voucherManagerWallet . connect ( TEST_CHAIN . provider ) ;
445436
0 commit comments