From 50b024a72e0d858843a9756c0b4832058fcb52fa Mon Sep 17 00:00:00 2001 From: hfuss Date: Fri, 21 Jan 2022 14:52:34 -0500 Subject: [PATCH 1/3] Support Using Either /abis or /gateways Signed-off-by: hfuss --- .env | 4 ++-- src/main.ts | 4 ++-- src/tokens/tokens.service.ts | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.env b/.env index a4d0ce8..c49c731 100644 --- a/.env +++ b/.env @@ -1,7 +1,7 @@ PORT=3000 ETHCONNECT_URL=http://127.0.0.1:5102 -ETHCONNECT_INSTANCE=/contracts/
+ETHCONNECT_INSTANCE=/contracts/
# if ethconnect has remote registry use /instances/
ETHCONNECT_TOPIC=token ETHCONNECT_PREFIX=fly AUTO_INIT=true -CONTRACT_ABI_ID= \ No newline at end of file +ETHCONNECT_CONTRACT_URI=/abis/ # if ethconnect has remote registry use /gateways/ diff --git a/src/main.ts b/src/main.ts index f97eb70..0f5a32a 100644 --- a/src/main.ts +++ b/src/main.ts @@ -61,7 +61,7 @@ async function bootstrap() { const topic = config.get('ETHCONNECT_TOPIC', 'token20'); const shortPrefix = config.get('ETHCONNECT_PREFIX', 'fly'); const autoInit = config.get('AUTO_INIT', 'true'); - const contractABI = config.get('CONTRACT_ABI_ID', ''); + const contractUri = config.get('ETHCONNECT_CONTRACT_URI', ''); const username = config.get('ETHCONNECT_USERNAME', ''); const password = config.get('ETHCONNECT_PASSWORD', ''); @@ -71,7 +71,7 @@ async function bootstrap() { app.get(EventStreamProxyGateway).configure(wsUrl, topic); app .get(TokensService) - .configure(ethConnectUrl, instancePath, topic, shortPrefix, contractABI, username, password); + .configure(ethConnectUrl, instancePath, topic, shortPrefix, contractUri, username, password); if (autoInit !== 'false') { await app.get(TokensService).init(); diff --git a/src/tokens/tokens.service.ts b/src/tokens/tokens.service.ts index 74c794f..b94d5da 100644 --- a/src/tokens/tokens.service.ts +++ b/src/tokens/tokens.service.ts @@ -66,7 +66,7 @@ export class TokensService { instanceUrl: string; topic: string; shortPrefix: string; - contractABI: string; + contractUri: string; contractInstanceUrl: string; stream: EventStream; username: string; @@ -83,7 +83,7 @@ export class TokensService { instancePath: string, topic: string, shortPrefix: string, - contractABI: string, + contractUri: string, username: string, password: string, ) { @@ -92,8 +92,8 @@ export class TokensService { this.instanceUrl = `${baseUrl}${instancePath}`; this.topic = topic; this.shortPrefix = shortPrefix; - this.contractABI = contractABI; - this.contractInstanceUrl = `${this.baseUrl}/abis/${contractABI}`; + this.contractUri = contractUri; + this.contractInstanceUrl = `${this.baseUrl}/${this.contractUri}`; this.username = username; this.password = password; this.proxy.addListener(new TokenListener(this, this.topic)); From 0e1c1f6d851eea263858914f1c6e76f69f84e3b5 Mon Sep 17 00:00:00 2001 From: hfuss Date: Fri, 21 Jan 2022 15:21:16 -0500 Subject: [PATCH 2/3] fixing e2e tests Signed-off-by: hfuss --- .env | 2 +- .gitignore | 1 + test/app.e2e-spec.ts | 12 ++++++------ test/ws.e2e-spec.ts | 4 ++-- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.env b/.env index c49c731..4cbdd34 100644 --- a/.env +++ b/.env @@ -4,4 +4,4 @@ ETHCONNECT_INSTANCE=/contracts/
# if ethc ETHCONNECT_TOPIC=token ETHCONNECT_PREFIX=fly AUTO_INIT=true -ETHCONNECT_CONTRACT_URI=/abis/ # if ethconnect has remote registry use /gateways/ +ETHCONNECT_CONTRACT_URI=abis/ # if ethconnect has remote registry use gateways/ diff --git a/.gitignore b/.gitignore index bebcc6a..2e7c243 100644 --- a/.gitignore +++ b/.gitignore @@ -22,6 +22,7 @@ solidity/build # IDEs and editors /.idea +*.iml .project .classpath .c9/ diff --git a/test/app.e2e-spec.ts b/test/app.e2e-spec.ts index 5129771..cf1bcb5 100644 --- a/test/app.e2e-spec.ts +++ b/test/app.e2e-spec.ts @@ -40,7 +40,7 @@ import { TokensService } from '../src/tokens/tokens.service'; import { AppModule } from './../src/app.module'; const BASE_URL = 'http://eth'; -const CONTRACT_ABI = '123'; +const CONTRACT_URI = 'abis/123'; const CONTRACT_ADDRESS = '0x123456'; const IDENTITY = '0x1'; const INSTANCE_PATH = '/tokens'; @@ -103,7 +103,7 @@ describe('AppController (e2e)', () => { await app.init(); app.get(EventStreamProxyGateway).configure('url', TOPIC); - app.get(TokensService).configure(BASE_URL, INSTANCE_PATH, TOPIC, PREFIX, CONTRACT_ABI, '', ''); + app.get(TokensService).configure(BASE_URL, INSTANCE_PATH, TOPIC, PREFIX, CONTRACT_URI, '', ''); (app.getHttpServer() as Server).listen(); server = request(app.getHttpServer()); @@ -253,7 +253,7 @@ describe('AppController (e2e)', () => { expect(http.post).toHaveBeenCalledTimes(1); expect(http.post).toHaveBeenCalledWith( - `${BASE_URL}/abis/${CONTRACT_ABI}/${CONTRACT_ADDRESS}/mintWithData`, + `${BASE_URL}/${CONTRACT_URI}/${CONTRACT_ADDRESS}/mintWithData`, { amount: '2', data: '0x74657374', @@ -282,7 +282,7 @@ describe('AppController (e2e)', () => { expect(http.post).toHaveBeenCalledTimes(1); expect(http.post).toHaveBeenCalledWith( - `${BASE_URL}/abis/${CONTRACT_ABI}/${CONTRACT_ADDRESS}/transferWithData`, + `${BASE_URL}/${CONTRACT_URI}/${CONTRACT_ADDRESS}/transferWithData`, { amount: '2', data: '0x00', @@ -311,7 +311,7 @@ describe('AppController (e2e)', () => { expect(http.post).toHaveBeenCalledTimes(1); expect(http.post).toHaveBeenCalledWith( - `${BASE_URL}/abis/${CONTRACT_ABI}/${CONTRACT_ADDRESS}/burnWithData`, + `${BASE_URL}/${CONTRACT_URI}/${CONTRACT_ADDRESS}/burnWithData`, { data: '0x747831', from: 'A', @@ -342,7 +342,7 @@ describe('AppController (e2e)', () => { expect(http.get).toHaveBeenCalledTimes(1); expect(http.get).toHaveBeenCalledWith( - `${BASE_URL}/abis/${CONTRACT_ABI}/${CONTRACT_ADDRESS}/balanceOf`, + `${BASE_URL}/${CONTRACT_URI}/${CONTRACT_ADDRESS}/balanceOf`, { params: { account: '1', diff --git a/test/ws.e2e-spec.ts b/test/ws.e2e-spec.ts index 2895e27..beadb0e 100644 --- a/test/ws.e2e-spec.ts +++ b/test/ws.e2e-spec.ts @@ -42,7 +42,7 @@ import { TokensService } from '../src/tokens/tokens.service'; import { WebSocketMessage } from '../src/websocket-events/websocket-events.base'; const BASE_URL = 'http://eth'; -const CONTRACT_ABI = '123'; +const CONTRACT_URI = 'abis/123'; const CONTRACT_ADDRESS = '0x123456'; const INSTANCE_PATH = '/tokens'; const ERC20_STANDARD = 'ERC20'; @@ -146,7 +146,7 @@ describe('WebSocket AppController (e2e)', () => { await app.init(); app.get(EventStreamProxyGateway).configure('url', TOPIC); - app.get(TokensService).configure(BASE_URL, INSTANCE_PATH, TOPIC, PREFIX, CONTRACT_ABI, '', ''); + app.get(TokensService).configure(BASE_URL, INSTANCE_PATH, TOPIC, PREFIX, CONTRACT_URI, '', ''); (app.getHttpServer() as Server).listen(); server = request(app.getHttpServer()); From 6eb6a66c368ed1adcb74347a9ada68028b23ba5b Mon Sep 17 00:00:00 2001 From: hfuss Date: Fri, 21 Jan 2022 15:37:57 -0500 Subject: [PATCH 3/3] consistent uri format Signed-off-by: hfuss --- .env | 2 +- src/tokens/tokens.service.ts | 4 ++-- test/app.e2e-spec.ts | 10 +++++----- test/ws.e2e-spec.ts | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.env b/.env index 4cbdd34..c49c731 100644 --- a/.env +++ b/.env @@ -4,4 +4,4 @@ ETHCONNECT_INSTANCE=/contracts/
# if ethc ETHCONNECT_TOPIC=token ETHCONNECT_PREFIX=fly AUTO_INIT=true -ETHCONNECT_CONTRACT_URI=abis/ # if ethconnect has remote registry use gateways/ +ETHCONNECT_CONTRACT_URI=/abis/ # if ethconnect has remote registry use /gateways/ diff --git a/src/tokens/tokens.service.ts b/src/tokens/tokens.service.ts index b94d5da..2cc40c5 100644 --- a/src/tokens/tokens.service.ts +++ b/src/tokens/tokens.service.ts @@ -89,11 +89,11 @@ export class TokensService { ) { this.baseUrl = baseUrl; this.instancePath = instancePath; - this.instanceUrl = `${baseUrl}${instancePath}`; + this.instanceUrl = `${this.baseUrl}${this.instancePath}`; this.topic = topic; this.shortPrefix = shortPrefix; this.contractUri = contractUri; - this.contractInstanceUrl = `${this.baseUrl}/${this.contractUri}`; + this.contractInstanceUrl = `${this.baseUrl}${this.contractUri}`; this.username = username; this.password = password; this.proxy.addListener(new TokenListener(this, this.topic)); diff --git a/test/app.e2e-spec.ts b/test/app.e2e-spec.ts index cf1bcb5..28b4d35 100644 --- a/test/app.e2e-spec.ts +++ b/test/app.e2e-spec.ts @@ -40,7 +40,7 @@ import { TokensService } from '../src/tokens/tokens.service'; import { AppModule } from './../src/app.module'; const BASE_URL = 'http://eth'; -const CONTRACT_URI = 'abis/123'; +const CONTRACT_URI = '/abis/123'; const CONTRACT_ADDRESS = '0x123456'; const IDENTITY = '0x1'; const INSTANCE_PATH = '/tokens'; @@ -253,7 +253,7 @@ describe('AppController (e2e)', () => { expect(http.post).toHaveBeenCalledTimes(1); expect(http.post).toHaveBeenCalledWith( - `${BASE_URL}/${CONTRACT_URI}/${CONTRACT_ADDRESS}/mintWithData`, + `${BASE_URL}${CONTRACT_URI}/${CONTRACT_ADDRESS}/mintWithData`, { amount: '2', data: '0x74657374', @@ -282,7 +282,7 @@ describe('AppController (e2e)', () => { expect(http.post).toHaveBeenCalledTimes(1); expect(http.post).toHaveBeenCalledWith( - `${BASE_URL}/${CONTRACT_URI}/${CONTRACT_ADDRESS}/transferWithData`, + `${BASE_URL}${CONTRACT_URI}/${CONTRACT_ADDRESS}/transferWithData`, { amount: '2', data: '0x00', @@ -311,7 +311,7 @@ describe('AppController (e2e)', () => { expect(http.post).toHaveBeenCalledTimes(1); expect(http.post).toHaveBeenCalledWith( - `${BASE_URL}/${CONTRACT_URI}/${CONTRACT_ADDRESS}/burnWithData`, + `${BASE_URL}${CONTRACT_URI}/${CONTRACT_ADDRESS}/burnWithData`, { data: '0x747831', from: 'A', @@ -342,7 +342,7 @@ describe('AppController (e2e)', () => { expect(http.get).toHaveBeenCalledTimes(1); expect(http.get).toHaveBeenCalledWith( - `${BASE_URL}/${CONTRACT_URI}/${CONTRACT_ADDRESS}/balanceOf`, + `${BASE_URL}${CONTRACT_URI}/${CONTRACT_ADDRESS}/balanceOf`, { params: { account: '1', diff --git a/test/ws.e2e-spec.ts b/test/ws.e2e-spec.ts index beadb0e..2366b4a 100644 --- a/test/ws.e2e-spec.ts +++ b/test/ws.e2e-spec.ts @@ -42,7 +42,7 @@ import { TokensService } from '../src/tokens/tokens.service'; import { WebSocketMessage } from '../src/websocket-events/websocket-events.base'; const BASE_URL = 'http://eth'; -const CONTRACT_URI = 'abis/123'; +const CONTRACT_URI = '/abis/123'; const CONTRACT_ADDRESS = '0x123456'; const INSTANCE_PATH = '/tokens'; const ERC20_STANDARD = 'ERC20';