Skip to content

Commit 06c54c4

Browse files
format
1 parent 2f9b242 commit 06c54c4

File tree

5 files changed

+36
-28
lines changed

5 files changed

+36
-28
lines changed

packages/sdk/src/config/config.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,35 +17,38 @@ export const CHAIN_CONFIG: Record<ChainId, ChainConfig> = {
1717
name: 'bellecour',
1818
dataprotectorContractAddress: '0x3a4ab33f3d605e75b6d00a32a0fa55c3628f6a59',
1919
sharingContractAddress: '0x1390c3c6a545198809f1c7c5dd2600ef74d60925',
20-
subgraphUrl: 'https://thegraph.iex.ec/subgraphs/name/bellecour/dataprotector-v2',
20+
subgraphUrl:
21+
'https://thegraph.iex.ec/subgraphs/name/bellecour/dataprotector-v2',
2122
ipfsGateway: 'https://ipfs-gateway.v8-bellecour.iex.ec',
2223
ipfsNode: 'https://ipfs-upload.v8-bellecour.iex.ec',
2324
smsDebugURL: 'https://sms-debug.iex.ec',
24-
workerpoolAddress:'prod-v8-bellecour.main.pools.iexec.eth'
25+
workerpoolAddress: 'prod-v8-bellecour.main.pools.iexec.eth',
2526
},
2627

2728
// Arbitrum
2829
42161: {
2930
name: 'arbitrum',
3031
dataprotectorContractAddress: '0xYourArbitrumContractAddress',
3132
sharingContractAddress: '0xYourArbitrumSharingAddress',
32-
subgraphUrl: 'https://api.thegraph.com/subgraphs/name/your/arbitrum-subgraph',
33+
subgraphUrl:
34+
'https://api.thegraph.com/subgraphs/name/your/arbitrum-subgraph',
3335
ipfsGateway: 'https://your-arbitrum-ipfs-gateway',
3436
ipfsNode: 'https://your-arbitrum-ipfs-node',
3537
smsDebugURL: 'https://your-arbitrum-sms-url',
36-
workerpoolAddress:'WorkerpoolAddress'
38+
workerpoolAddress: 'WorkerpoolAddress',
3739
},
3840

39-
// Avalanche
41+
// Avalanche
4042
43114: {
4143
name: 'avalanche',
4244
dataprotectorContractAddress: '0xYourAvalancheContractAddress',
4345
sharingContractAddress: '0xYourAvalancheSharingAddress',
44-
subgraphUrl: 'https://api.thegraph.com/subgraphs/name/your/avalanche-subgraph',
46+
subgraphUrl:
47+
'https://api.thegraph.com/subgraphs/name/your/avalanche-subgraph',
4548
ipfsGateway: 'https://your-avalanche-ipfs-gateway',
4649
ipfsNode: 'https://your-avalanche-ipfs-node',
4750
smsDebugURL: 'https://your-avalanche-sms-url',
48-
workerpoolAddress:'WorkerpoolAddress'
51+
workerpoolAddress: 'WorkerpoolAddress',
4952
},
5053
};
5154

packages/sdk/src/lib/IExecDataProtectorModule.ts

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
1-
import {
2-
AbstractProvider,
3-
AbstractSigner,
4-
Eip1193Provider,
5-
} from 'ethers';
1+
import { AbstractProvider, AbstractSigner, Eip1193Provider } from 'ethers';
62
import { GraphQLClient } from 'graphql-request';
73
import { IExec } from 'iexec';
8-
import {
9-
CHAIN_CONFIG,
10-
} from '../config/config.js';
4+
import { CHAIN_CONFIG } from '../config/config.js';
115
import { getChainIdFromProvider } from '../utils/getChainId.js';
126
import {
137
AddressOrENS,
@@ -80,24 +74,35 @@ abstract class IExecDataProtectorModule {
8074
const chainId = await getChainIdFromProvider(this.ethProvider);
8175
const chainDefaultConfig = CHAIN_CONFIG[chainId];
8276

83-
const subgraphUrl = this.options?.subgraphUrl || chainDefaultConfig?.subgraphUrl;
84-
const dataprotectorContractAddress = this.options?.dataprotectorContractAddress || chainDefaultConfig?.dataprotectorContractAddress;
85-
const sharingContractAddress = this.options?.sharingContractAddress || chainDefaultConfig?.sharingContractAddress;
86-
const ipfsGateway = this.options?.ipfsGateway || chainDefaultConfig?.ipfsGateway;
77+
const subgraphUrl =
78+
this.options?.subgraphUrl || chainDefaultConfig?.subgraphUrl;
79+
const dataprotectorContractAddress =
80+
this.options?.dataprotectorContractAddress ||
81+
chainDefaultConfig?.dataprotectorContractAddress;
82+
const sharingContractAddress =
83+
this.options?.sharingContractAddress ||
84+
chainDefaultConfig?.sharingContractAddress;
85+
const ipfsGateway =
86+
this.options?.ipfsGateway || chainDefaultConfig?.ipfsGateway;
8787
const ipfsNode = this.options?.ipfsNode || chainDefaultConfig?.ipfsNode;
88-
const smsURL = this.options?.iexecOptions?.smsDebugURL || chainDefaultConfig?.smsDebugURL;
88+
const smsURL =
89+
this.options?.iexecOptions?.smsDebugURL ||
90+
chainDefaultConfig?.smsDebugURL;
8991

9092
const missing = [];
9193
if (!subgraphUrl) missing.push('subgraphUrl');
92-
if (!dataprotectorContractAddress) missing.push('dataprotectorContractAddress');
94+
if (!dataprotectorContractAddress)
95+
missing.push('dataprotectorContractAddress');
9396
if (!sharingContractAddress) missing.push('sharingContractAddress');
9497
if (!ipfsGateway) missing.push('ipfsGateway');
9598
if (!ipfsNode) missing.push('ipfsNode');
9699
if (!smsURL) missing.push('smsDebugURL');
97100

98101
if (missing.length > 0) {
99102
throw new Error(
100-
`Missing required configuration for chainId ${chainId}: ${missing.join(', ')}`
103+
`Missing required configuration for chainId ${chainId}: ${missing.join(
104+
', '
105+
)}`
101106
);
102107
}
103108

packages/sdk/src/lib/dataProtectorCore/processProtectedData.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export const processProtectedData = async ({
102102
validateOnStatusUpdateCallback<
103103
OnStatusUpdateFn<ProcessProtectedDataStatuses>
104104
>(onStatusUpdate);
105-
105+
106106
let requester = await iexec.wallet.getAddress();
107107
if (vUserWhitelist) {
108108
const isValidWhitelist = await isERC734(iexec, vUserWhitelist);
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import type { IExecModule } from 'iexec';
22
import type { IPoCo } from '../../../../generated/typechain/sharing/interfaces/IPoCo.js';
33

4-
export async function getPocoContract(
5-
iexec: IExecModule
6-
): Promise<IPoCo> {
4+
export async function getPocoContract(iexec: IExecModule): Promise<IPoCo> {
75
const client = await iexec.config.resolveContractsClient();
86
return client.getIExecContract() as unknown as IPoCo;
97
}

packages/sdk/src/utils/getChainId.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {
33
BrowserProvider,
44
AbstractProvider,
55
AbstractSigner,
6-
Eip1193Provider
6+
Eip1193Provider,
77
} from 'ethers';
88
import { DEFAULT_CHAIN_ID } from '../config/config.js';
99

@@ -13,7 +13,9 @@ type EthersCompatibleProvider =
1313
| AbstractSigner
1414
| Eip1193Provider;
1515

16-
export async function getChainIdFromProvider(ethProvider: EthersCompatibleProvider): Promise<number> {
16+
export async function getChainIdFromProvider(
17+
ethProvider: EthersCompatibleProvider
18+
): Promise<number> {
1719
try {
1820
if (typeof ethProvider === 'string') {
1921
const provider = new JsonRpcProvider(ethProvider);

0 commit comments

Comments
 (0)