Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add amoy network #27

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
726 changes: 378 additions & 348 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
},
"dependencies": {
"axios": "^1.5.0",
"ipfs-http-client": "59.0.0",
"ipfs-http-client": "^60.0.1",
"tsup": "7.2.0",
"viem": "^1.10.14"
}
}
}
4 changes: 2 additions & 2 deletions packages/client/src/__tests__/talentLayerClient.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ describe('TalentLayerClient', () => {
describe('getChainConfig', () => {
it('should return the chain config based on the network id passed', () => {
// Arrange
const networkId = NetworkEnum.MUMBAI;
const networkId = NetworkEnum.AMOY;

// Act
const config = client.getChainConfig(networkId);
Expand Down Expand Up @@ -195,7 +195,7 @@ describe('TalentLayerClient:dev', () => {
describe('getChainConfig', () => {
it('should return the chain config irrespective of the network id passed', () => {
// Arrange
const networkId = NetworkEnum.MUMBAI;
const networkId = NetworkEnum.AMOY;

// Act
const config = client.getChainConfig(networkId);
Expand Down
32 changes: 31 additions & 1 deletion packages/client/src/blockchain-bindings/chains.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineChain } from 'viem';
import { polygon, polygonMumbai } from 'viem/chains';
import { polygon, polygonMumbai, avalancheFuji } from 'viem/chains';
import { NetworkEnum } from '../types';

// @ts-ignore
Expand Down Expand Up @@ -29,8 +29,38 @@ const iexec = defineChain({
testnet: false,
});

export const polygonAmoy = defineChain({
id: 80002,
name: 'Polygon Amoy',
nativeCurrency: { name: 'MATIC', symbol: 'MATIC', decimals: 18 },
rpcUrls: {
default: {
http: ['https://rpc-amoy.polygon.technology'],
},
public: {
http: ['https://rpc-amoy.polygon.technology'],
},
},
blockExplorers: {
default: {
name: 'PolygonScan',
url: 'https://amoy.polygonscan.com/',
},
},
contracts: {
multicall3: {
address: '0xca11bde05977b3631167028862be2a173976ca11',
blockCreated: 3127388,
},
},
testnet: true,
network: "polygon"
})

export const chains = {
[NetworkEnum.MUMBAI]: polygonMumbai,
[NetworkEnum.AMOY]: polygonAmoy,
[NetworkEnum.IEXEC]: iexec,
[NetworkEnum.POLYGON]: polygon,
[NetworkEnum.FUJI]: avalancheFuji,
};
102 changes: 102 additions & 0 deletions packages/client/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,56 @@ import TalentLayerEscrow from './contracts/ABI/TalentLayerEscrow.json';
import TalentLayerPlatformID from './contracts/ABI/TalentLayerPlatformID.json';
import TalentLayerArbitrator from './contracts/ABI/TalentLayerArbitrator.json';

const amoy: Config = {
networkId: NetworkEnum.AMOY,
subgraphUrl: 'https://api.studio.thegraph.com/query/41228/tl-graph-amoy/v0.0.1',
contracts: {
talentLayerId: {
address: '0xBe0d91F2371e23b9A26Fb8949E041A65dD0aDe83',
abi: TalentLayerID.abi,
},
talentLayerService: {
address: '0x5394632Fe8044BF3c3eF6fBD30d1121d5d796542',
abi: TalerLayerService.abi,
},
talentLayerReview: {
address: '0x194D3a30Ad6274F169c78D64A538a8F472c47819',
abi: TalentLayerReview.abi,
},
talentLayerEscrow: {
address: '0x466e65231DBe87b184c7cEeE8A319b4aB117915B',
abi: TalentLayerEscrow.abi,
},
talentLayerPlatformId: {
address: '0xbE56916C64f80040d46Ea5B32E1e851cE752cD3f',
abi: TalentLayerPlatformID.abi,
},
talentLayerArbitrator: {
address: '0x0F39E0ffEaBE0C100768F16988F0c9405428E2D8',
abi: TalentLayerArbitrator.abi,
},
},
escrowConfig: {
adminFee: '0',
adminWallet: '0xC01FcDfDE3B2ABA1eab76731493C617FfAED2F10',
timeoutPayment: 3600 * 24 * 7,
},
tokens: {
[AddressZero]: {
address: AddressZero,
symbol: 'MATIC',
name: 'Matic',
decimals: 18,
},
'0xe6b8a5CF854791412c1f6EFC7CAf629f5Df1c747': {
address: '0xe6b8a5CF854791412c1f6EFC7CAf629f5Df1c747',
symbol: 'USDC',
name: 'USDC Stablecoin',
decimals: 6,
},
},
};

const mumbai: Config = {
networkId: NetworkEnum.MUMBAI,
subgraphUrl: 'https://api.thegraph.com/subgraphs/name/talentlayer/talent-layer-mumbai',
Expand Down Expand Up @@ -163,10 +213,62 @@ const polygon: Config = {
},
};

const fuji: Config = {
networkId: NetworkEnum.FUJI,
subgraphUrl: 'https://api.studio.thegraph.com/query/41228/tl-graph-fuji/version/latest',
contracts: {
talentLayerId: {
address: '0x11BF027d41011a050c77E3BE7fB1942500C29928',
abi: TalentLayerID.abi,
},
talentLayerService: {
address: '0x037a42146f7803Ac85Eeb201A8aab483E10c3E1A',
abi: TalerLayerService.abi,
},
talentLayerReview: {
address: '0x5b1e55ca26f8128155f35a0c5804e292B1b66bb7',
abi: TalentLayerReview.abi,
},
talentLayerEscrow: {
address: '0x2D11f75E4af6626bA457532429D5FA6bF18ac011',
abi: TalentLayerEscrow.abi,
},
talentLayerPlatformId: {
address: '0x5582d6493449a9c8aE353715eaE55794056dBF19',
abi: TalentLayerPlatformID.abi,
},
talentLayerArbitrator: {
address: '0x0000000000000000000000000000000000000000', // TODO: update
abi: TalentLayerArbitrator.abi,
},
},
escrowConfig: {
adminFee: '0',
adminWallet: '0x754edfB906252B304f89c59c61f4368028bdcE6c',
timeoutPayment: 3600 * 24 * 7,
},
tokens: {
['0x0000000000000000000000000000000000000000']: {
address: '0x0000000000000000000000000000000000000000',
symbol: 'AVAX',
name: 'Avax',
decimals: 18,
},
'0xAF82969ECF299c1f1Bb5e1D12dDAcc9027431160': {
address: '0xAF82969ECF299c1f1Bb5e1D12dDAcc9027431160',
symbol: 'USDC',
name: 'USDC Stablecoin',
decimals: 6,
},
},
};

const chains: { [networkId in NetworkEnum]: Config } = {
[NetworkEnum.AMOY]: amoy,
[NetworkEnum.MUMBAI]: mumbai,
[NetworkEnum.IEXEC]: iexec,
[NetworkEnum.POLYGON]: polygon,
[NetworkEnum.FUJI]: fuji,
// This value is a place holder. The local value is provided through
// dev config when using the sdk in dev mode
[NetworkEnum.LOCAL]: mumbai,
Expand Down
2 changes: 2 additions & 0 deletions packages/client/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ export type IToken = {

export enum NetworkEnum {
MUMBAI = 80001,
AMOY = 80002,
IEXEC = 134,
POLYGON = 137,
FUJI = 43113,
LOCAL = 1,
}

Expand Down
4 changes: 2 additions & 2 deletions packages/client/src/viem/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ export class ViemClient {
constructor(chainId: NetworkEnum, config: ViemClientConfig, logger: Logger, customConfig?: CustomConfig) {
logger.info('Wallet Client initialising with viem')
// dev config chain Id is prioritized.
// If chainId is not provided, set it to mumbai
this.chainId = customConfig?.chainConfig.id || chainId || config.chainId || NetworkEnum.MUMBAI;
// If chainId is not provided, set it to amoy
this.chainId = customConfig?.chainConfig.id || chainId || config.chainId || NetworkEnum.AMOY;
this.customConfig = customConfig;
this.logger = logger;

Expand Down
Loading