Skip to content

Commit 10c5e42

Browse files
committed
refactor: squash unsigned commits
-S refactor: add goerli tests refactor: add goerli tests refactor: add goerli tests feat: add goerli support in currency -S feat: add goerli payment-detection tests refactor: setups.ts refactor: goerli tests refactor: goerli contract address in tests refactor: goerli tests refactor: rename ETHConversionProxy to EthConversionProxy
1 parent 173d118 commit 10c5e42

File tree

18 files changed

+460
-171
lines changed

18 files changed

+460
-171
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"0xba62bcfcaafc6622853cca2be6ac7d845bc0f2dc": {
3+
"0x775eb53d00dd0acd3ec1696472105d579b9b386b": 1
4+
},
5+
"0x775eb53d00dd0acd3ec1696472105d579b9b386b": {
6+
"0xba62bcfcaafc6622853cca2be6ac7d845bc0f2dc": 1
7+
}
8+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { TokenMap } from './types';
2+
3+
// List of the supported goerli ERC20 tokens
4+
export const supportedGoerliERC20: TokenMap = {
5+
// Request Test token, used for testing on goerli.
6+
'0x7af963cF6D228E564e2A0aA0DdBF06210B38615D': {
7+
decimals: 18,
8+
name: 'Goerli Test Token',
9+
symbol: 'TST',
10+
},
11+
// Faucet Token on goerli network. Easy to use on tests.
12+
'0xBA62BCfcAaFc6622853cca2BE6Ac7d845BC0f2Dc': {
13+
decimals: 18,
14+
name: 'Faucet Token',
15+
symbol: 'FAU-goerli',
16+
},
17+
};

packages/payment-detection/src/erc20/address-based.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { BalanceError } from '../balance-error';
88
import Erc20InfoRetriever from './address-based-info-retriever';
99

1010
import { PaymentDetectorBase } from '../payment-detector-base';
11-
const supportedNetworks = ['mainnet', 'rinkeby', 'private'];
11+
const supportedNetworks = ['mainnet', 'rinkeby', 'goerli', 'private'];
1212

1313
/**
1414
* Handle payment networks with ERC20 based address extension

packages/payment-detection/test/any/any-to-erc20-proxy-contract.test.ts

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const mockAdvancedLogic: AdvancedLogicTypes.IAdvancedLogic = {
3131
},
3232
extensions: {
3333
anyToErc20Proxy: {
34-
supportedNetworks: ['mainnet', 'rinkeby', 'private'],
34+
supportedNetworks: ['mainnet', 'rinkeby', 'goerli', 'private'],
3535
createAddPaymentAddressAction,
3636
createAddRefundAddressAction,
3737
createCreationAction,
@@ -56,7 +56,7 @@ describe('api/any/conversion-fee-proxy-contract', () => {
5656
jest.clearAllMocks();
5757
});
5858

59-
it('can createExtensionsDataForCreation', async () => {
59+
it('can createExtensionsDataForCreation (Rinkeby)', async () => {
6060
await anyToErc20Proxy.createExtensionsDataForCreation({
6161
paymentAddress: 'ethereum address',
6262
salt: 'ea3bc7caf64110ca',
@@ -77,7 +77,28 @@ describe('api/any/conversion-fee-proxy-contract', () => {
7777
});
7878
});
7979

80-
it('can createExtensionsDataForCreation with fee amount and address', async () => {
80+
it('can createExtensionsDataForCreation (Goerli)', async () => {
81+
await anyToErc20Proxy.createExtensionsDataForCreation({
82+
paymentAddress: 'ethereum address',
83+
salt: 'ea3bc7caf64110ca',
84+
acceptedTokens: ['ethereum address2'],
85+
network: 'goerli',
86+
maxRateTimespan: 1000,
87+
});
88+
89+
expect(createCreationAction).toHaveBeenCalledWith({
90+
feeAddress: undefined,
91+
feeAmount: undefined,
92+
paymentAddress: 'ethereum address',
93+
refundAddress: undefined,
94+
salt: 'ea3bc7caf64110ca',
95+
acceptedTokens: ['ethereum address2'],
96+
network: 'goerli',
97+
maxRateTimespan: 1000,
98+
});
99+
});
100+
101+
it('can createExtensionsDataForCreation with fee amount and address (Rinkeby)', async () => {
81102
await anyToErc20Proxy.createExtensionsDataForCreation({
82103
feeAddress: 'fee address',
83104
feeAmount: '2000',
@@ -98,6 +119,27 @@ describe('api/any/conversion-fee-proxy-contract', () => {
98119
});
99120
});
100121

122+
it('can createExtensionsDataForCreation with fee amount and address (Goerli)', async () => {
123+
await anyToErc20Proxy.createExtensionsDataForCreation({
124+
feeAddress: 'fee address',
125+
feeAmount: '2000',
126+
paymentAddress: 'ethereum address',
127+
salt: 'ea3bc7caf64110ca',
128+
acceptedTokens: ['ethereum address2'],
129+
network: 'goerli',
130+
});
131+
132+
expect(createCreationAction).toHaveBeenCalledWith({
133+
feeAddress: 'fee address',
134+
feeAmount: '2000',
135+
paymentAddress: 'ethereum address',
136+
refundAddress: undefined,
137+
salt: 'ea3bc7caf64110ca',
138+
acceptedTokens: ['ethereum address2'],
139+
network: 'goerli',
140+
});
141+
});
142+
101143
it('can createExtensionsDataForCreation without salt', async () => {
102144
await anyToErc20Proxy.createExtensionsDataForCreation({
103145
paymentAddress: 'ethereum address',

packages/payment-detection/test/erc20/address-based.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ describe('api/erc20/address-based', () => {
126126
error: {
127127
code: PaymentTypes.BALANCE_ERROR_CODE.NETWORK_NOT_SUPPORTED,
128128
message:
129-
'Payment network wrong not supported by ERC20 payment detection. Supported networks: mainnet, rinkeby, private',
129+
'Payment network wrong not supported by ERC20 payment detection. Supported networks: mainnet, rinkeby, goerli, private',
130130
},
131131
events: [],
132132
});

packages/payment-detection/test/erc20/escrow-info-retriever.test.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,4 +161,30 @@ describe('api/erc20/escrow-info-retriever', () => {
161161
expect(escrowChainData.isFrozen).toEqual(true);
162162
});
163163
});
164+
165+
describe('test on goerli', () => {
166+
let infoRetriever: EscrowERC20InfoRetriever;
167+
beforeAll(() => {
168+
infoRetriever = new EscrowERC20InfoRetriever(
169+
paymentReferenceMock,
170+
'0x8230e703B1c4467A4543422b2cC3284133B9AB5e',
171+
0,
172+
'',
173+
'',
174+
'goerli',
175+
);
176+
});
177+
it('should get escrow chain data', async () => {
178+
const escrowChainData = await infoRetriever.getEscrowRequestMapping();
179+
// Not yet ERC777 token on goerli
180+
// expect(escrowChainData.tokenAddress).toEqual('0x745861AeD1EEe363b4AaA5F1994Be40b1e05Ff90');
181+
expect(escrowChainData.payee).toEqual('0xB9B7e0cb2EDF5Ea031C8B297A5A1Fa20379b6A0a');
182+
expect(escrowChainData.payer).toEqual('0x0c051a1f4E209b00c8E7C00AD0ce79B3630a7401');
183+
expect(escrowChainData.amount.toString()).toEqual('123000000000000000000');
184+
expect(escrowChainData.unlockDate.toString()).toEqual('1670505020');
185+
expect(escrowChainData.emergencyClaimDate.toString()).toEqual('0');
186+
expect(escrowChainData.emergencyState).toEqual(false);
187+
expect(escrowChainData.isFrozen).toEqual(true);
188+
});
189+
});
164190
});

packages/payment-detection/test/erc20/fee-proxy-contract.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const mockAdvancedLogic: AdvancedLogicTypes.IAdvancedLogic = {
2323
},
2424
extensions: {
2525
feeProxyContractErc20: {
26-
supportedNetworks: ['mainnet', 'private', 'rinkeby'],
26+
supportedNetworks: ['mainnet', 'private', 'rinkeby', 'goerli'],
2727
createAddPaymentAddressAction,
2828
createAddRefundAddressAction,
2929
createCreationAction,
@@ -283,7 +283,7 @@ describe('api/erc20/fee-proxy-contract', () => {
283283
).toBe('7');
284284
});
285285

286-
it('should have gasFee & gasUsed in the payment eventl', async () => {
286+
it('should have gasFee & gasUsed in the payment event', async () => {
287287
const mockRequest: RequestLogicTypes.IRequest = {
288288
creator: { type: IdentityTypes.TYPE.ETHEREUM_ADDRESS, value: '0x2' },
289289
currency: {

packages/payment-detection/test/erc20/proxy-contract.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const mockAdvancedLogic: AdvancedLogicTypes.IAdvancedLogic = {
2525
},
2626
extensions: {
2727
proxyContractErc20: {
28-
supportedNetworks: ['mainnet', 'rinkeby'],
28+
supportedNetworks: ['mainnet', 'rinkeby', 'goerli'],
2929
createAddPaymentAddressAction,
3030
createAddRefundAddressAction,
3131
createCreationAction,
@@ -160,7 +160,7 @@ describe('api/erc20/proxy-contract', () => {
160160
error: {
161161
code: PaymentTypes.BALANCE_ERROR_CODE.NETWORK_NOT_SUPPORTED,
162162
message:
163-
'Payment network WRONG not supported by pn-erc20-proxy-contract payment detection. Supported networks: mainnet, rinkeby',
163+
'Payment network WRONG not supported by pn-erc20-proxy-contract payment detection. Supported networks: mainnet, rinkeby, goerli',
164164
},
165165
events: [],
166166
});

packages/payment-detection/test/erc20/thegraph-info-retriever.test.ts

Lines changed: 86 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ describe('api/erc20/thegraph-info-retriever', () => {
5151
expect(transferEvents[0].parameters?.feeAmount).toEqual(paymentData.feeAmount);
5252
});
5353

54-
it('should get payment event from ethFeeConversionProxy via subgraph', async () => {
54+
it('should get payment event from ethFeeConversionProxy via subgraph (Rinkeby)', async () => {
5555
const paymentData = {
5656
reference: '0x6c93723bc5f82e6fbb2ea994bf0fb572fa19f7a2a3146065e21752b95668efe5',
5757
txHash: '0x2f7b4752aa259166c038cd9073056c5979760cf0eea55d093fca2095c229313b',
@@ -89,4 +89,89 @@ describe('api/erc20/thegraph-info-retriever', () => {
8989
expect(transferEvents[0].parameters?.block).toEqual(paymentData.block);
9090
});
9191
});
92+
93+
describe('on goerli', () => {
94+
const GOERLI_ETH_FEE_PROXY_CONTRACT = '0xe11BF2fDA23bF0A98365e1A4c04A87C9339e8687';
95+
const GOERLI_ETH_CONVERSION_PROXY_CONTRACT = '0xED250D9219EB93098Bb67aEbc992963172B9c8DA';
96+
97+
it('should get payment event from ethFeeProxy via subgraph', async () => {
98+
const paymentData = {
99+
reference: '0x6c93723bc5f82e6fbb2ea994bf0fb572fa19f7a2a3146065e21752b95668efe5',
100+
txHash: '0x3e2d6cc2534b1d340ba2954f34e6cc819d6da64ff76863ea89c6d34b15d13c97',
101+
from: '0x186e7fe6c34ea0eca7f9c2fd29651fc0443e3f29',
102+
to: '0x5000ee9fb9c96a2a09d8efb695ac21d6c429ff11',
103+
network: 'goerli',
104+
salt: '0ee84db293a752c6',
105+
amount: '30000000000000',
106+
requestId: '0188791633ff0ec72a7dbdefb886d2db6cccfa98287320839c2f173c7a4e3ce7e1',
107+
block: 9606098,
108+
feeAddress: '0x5000EE9FB9c96A2A09D8efB695aC21D6C429fF11',
109+
feeAmount: '0',
110+
};
111+
const paymentReference = PaymentReferenceCalculator.calculate(
112+
paymentData.requestId,
113+
paymentData.salt,
114+
paymentData.to,
115+
);
116+
const onChainReference = utils.keccak256(`0x${paymentReference}`);
117+
expect(onChainReference).toEqual(paymentData.reference);
118+
119+
const graphRetriever = new TheGraphInfoRetriever(
120+
paymentReference,
121+
GOERLI_ETH_FEE_PROXY_CONTRACT,
122+
null,
123+
paymentData.to,
124+
PaymentTypes.EVENTS_NAMES.PAYMENT,
125+
paymentData.network,
126+
);
127+
const allNetworkEvents = await graphRetriever.getTransferEvents();
128+
const transferEvents = allNetworkEvents.paymentEvents;
129+
// expect(transferEvents).toHaveLength(1);
130+
expect(transferEvents[0].amount).toEqual('30000000000000');
131+
expect(transferEvents[0].name).toEqual('payment');
132+
expect(transferEvents[0].parameters?.to).toEqual(paymentData.to);
133+
expect(transferEvents[0].parameters?.txHash).toEqual(paymentData.txHash);
134+
expect(transferEvents[0].parameters?.block).toEqual(paymentData.block);
135+
expect(transferEvents[0].parameters?.feeAddress).toEqual(paymentData.feeAddress);
136+
expect(transferEvents[0].parameters?.feeAmount).toEqual(paymentData.feeAmount);
137+
});
138+
139+
it('should get payment event from ethFeeConversionProxy via subgraph', async () => {
140+
const paymentData = {
141+
reference: '0x6c93723bc5f82e6fbb2ea994bf0fb572fa19f7a2a3146065e21752b95668efe5',
142+
txHash: '0x2f7b4752aa259166c038cd9073056c5979760cf0eea55d093fca2095c229313b',
143+
from: '0x186e7fe6c34ea0eca7f9c2fd29651fc0443e3f29',
144+
to: '0x5000ee9fb9c96a2a09d8efb695ac21d6c429ff11',
145+
network: 'goerli',
146+
salt: '0ee84db293a752c6',
147+
amount: '7000',
148+
block: 9610470,
149+
requestId: '0188791633ff0ec72a7dbdefb886d2db6cccfa98287320839c2f173c7a4e3ce7e1',
150+
};
151+
152+
const shortReference = PaymentReferenceCalculator.calculate(
153+
paymentData.requestId,
154+
paymentData.salt,
155+
paymentData.to,
156+
);
157+
const onChainReference = utils.keccak256(`0x${shortReference}`);
158+
expect(onChainReference).toEqual(paymentData.reference);
159+
160+
const graphRetriever = new TheGraphInfoRetriever(
161+
shortReference,
162+
GOERLI_ETH_CONVERSION_PROXY_CONTRACT,
163+
null,
164+
paymentData.to,
165+
PaymentTypes.EVENTS_NAMES.PAYMENT,
166+
paymentData.network,
167+
);
168+
const allNetworkEvents = await graphRetriever.getTransferEvents();
169+
const transferEvents = allNetworkEvents.paymentEvents;
170+
// expect(transferEvents).toHaveLength(1);
171+
expect(transferEvents[0].amount).toEqual(paymentData.amount);
172+
expect(transferEvents[0].parameters?.to).toEqual(paymentData.to);
173+
expect(transferEvents[0].parameters?.txHash).toEqual(paymentData.txHash);
174+
expect(transferEvents[0].parameters?.block).toEqual(paymentData.block);
175+
});
176+
});
92177
});

packages/payment-detection/test/erc777/mocks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ const mockFlows = [
7676
},
7777
{
7878
transactionHash: '0xe472ca1b52751b058fbdaeaffebd98c0cc43b45aa31794b3eb06834ede19f7be',
79-
blockNumber: '9945543',
79+
blockNumber: 9945543,
8080
timestamp: '1641495767',
8181
sender: '0x9c040e2d6fd83a8b35069aa7154b69674961e0f7',
8282
flowRate: '0',

0 commit comments

Comments
 (0)