From b5677c0579dfd8ed242dd14d399614716092d302 Mon Sep 17 00:00:00 2001 From: Andrew Richardson Date: Tue, 1 Mar 2022 14:30:09 -0500 Subject: [PATCH] Rename "operator" to "signer" in FireFly calls Signed-off-by: Andrew Richardson --- README.md | 8 ++++---- src/tokens/tokens.interfaces.ts | 6 +++--- src/tokens/tokens.service.spec.ts | 20 ++++++++++---------- src/tokens/tokens.service.ts | 22 +++++++++++----------- test/erc20.e2e-spec.ts | 20 ++++++++++---------- test/ws.e2e-spec.ts | 12 ++++++------ 6 files changed, 44 insertions(+), 44 deletions(-) diff --git a/README.md b/README.md index ffcc222..6b1e4bb 100644 --- a/README.md +++ b/README.md @@ -39,10 +39,10 @@ not require any acknowledgment). Successful POST operations will also result in a detailed event corresponding to the type of transaction that was performed. The events and corresponding data items are: -* `token-pool` - Token pool created (outputs: poolId, operator, data) -* `token-mint` - Tokens minted (outputs: id, poolId, tokenIndex, operator, to, amount, data) -* `token-burn` - Tokens burned (outputs: id, poolId, tokenIndex, operator, from, amount, data) -* `token-transfer` - Tokens transferred (outputs: id, poolId, operator, from, to, amount, data) +* `token-pool` - Token pool created (outputs: poolId, signer, data) +* `token-mint` - Tokens minted (outputs: id, poolId, tokenIndex, signer, to, amount, data) +* `token-burn` - Tokens burned (outputs: id, poolId, tokenIndex, signer, from, amount, data) +* `token-transfer` - Tokens transferred (outputs: id, poolId, signer, from, to, amount, data) If multiple websocket clients are connected, only one will receive these events. Each one of these _must_ be acknowledged by replying on the websocket with `{event: "ack", data: {id}}`. diff --git a/src/tokens/tokens.interfaces.ts b/src/tokens/tokens.interfaces.ts index e89af10..f34f6ef 100644 --- a/src/tokens/tokens.interfaces.ts +++ b/src/tokens/tokens.interfaces.ts @@ -80,7 +80,7 @@ export class TokenPool { @ApiProperty() @IsNotEmpty() - operator: string; + signer: string; @ApiProperty() @IsNotEmpty() @@ -156,7 +156,7 @@ export class TokenTransfer { @ApiProperty() @IsNotEmpty() - operator: string; + signer: string; @ApiProperty() @IsNotEmpty() @@ -185,7 +185,7 @@ class tokenEventBase { data?: string; @ApiProperty() - operator?: string; + signer?: string; @ApiProperty() rawOutput?: any; diff --git a/src/tokens/tokens.service.spec.ts b/src/tokens/tokens.service.spec.ts index 3497dac..e175d9a 100644 --- a/src/tokens/tokens.service.spec.ts +++ b/src/tokens/tokens.service.spec.ts @@ -146,7 +146,7 @@ describe('TokensService', () => { const request: TokenPool = { type: TokenType.FUNGIBLE, requestId: REQUEST, - operator: IDENTITY, + signer: IDENTITY, data: `{"tx":${TX}}`, config: { address: CONTRACT_ADDRESS }, name: NAME, @@ -166,7 +166,7 @@ describe('TokensService', () => { const request: TokenPool = { type: TokenType.NONFUNGIBLE, requestId: REQUEST, - operator: IDENTITY, + signer: IDENTITY, data: `{"tx":${TX}}`, config: { address: CONTRACT_ADDRESS }, name: NAME, @@ -283,7 +283,7 @@ describe('TokensService', () => { it('should mint ERC20 token with correct abi and inputs', async () => { const request: TokenMint = { amount: '20', - operator: IDENTITY, + signer: IDENTITY, poolId: ERC20_POOL_ID, to: '0x123', }; @@ -314,7 +314,7 @@ describe('TokensService', () => { const request: TokenMint = { amount: '2', tokenIndex: '721', - operator: IDENTITY, + signer: IDENTITY, poolId: ERC721_POOL_ID, to: '0x123', }; @@ -326,7 +326,7 @@ describe('TokensService', () => { it('should mint ERC721 token with correct abi and inputs', async () => { const request: TokenMint = { tokenIndex: '721', - operator: IDENTITY, + signer: IDENTITY, poolId: ERC721_POOL_ID, to: '0x123', }; @@ -358,7 +358,7 @@ describe('TokensService', () => { it('should transfer ERC20 token with correct abi and inputs', async () => { const request: TokenTransfer = { amount: '20', - operator: IDENTITY, + signer: IDENTITY, poolId: ERC20_POOL_ID, from: IDENTITY, to: '0x123', @@ -391,7 +391,7 @@ describe('TokensService', () => { it('should transfer ERC721 token with correct abi and inputs', async () => { const request: TokenTransfer = { tokenIndex: '721', - operator: IDENTITY, + signer: IDENTITY, poolId: ERC721_POOL_ID, from: IDENTITY, to: '0x123', @@ -424,7 +424,7 @@ describe('TokensService', () => { it('should burn ERC20 token with correct abi and inputs', async () => { const request: TokenBurn = { amount: '20', - operator: IDENTITY, + signer: IDENTITY, poolId: ERC20_POOL_ID, from: IDENTITY, }; @@ -454,7 +454,7 @@ describe('TokensService', () => { it('should burn ERC721 token with correct abi and inputs', async () => { const request: TokenBurn = { tokenIndex: '721', - operator: IDENTITY, + signer: IDENTITY, poolId: ERC721_POOL_ID, from: IDENTITY, }; @@ -484,7 +484,7 @@ describe('TokensService', () => { }); }); - describe('getters for balance/receipt/operator', () => { + describe('getter for receipt', () => { it('should get receipt of id successfully', async () => { const response: EventStreamReply = { headers: { diff --git a/src/tokens/tokens.service.ts b/src/tokens/tokens.service.ts index 268b25f..4b5c913 100644 --- a/src/tokens/tokens.service.ts +++ b/src/tokens/tokens.service.ts @@ -159,14 +159,14 @@ export class TokensService { return; } - private postOptions(operator: string, requestId?: string) { + private postOptions(signer: string, requestId?: string) { const from = `${this.shortPrefix}-from`; const sync = `${this.shortPrefix}-sync`; const id = `${this.shortPrefix}-id`; const requestOptions: AxiosRequestConfig = { params: { - [from]: operator, + [from]: signer, [sync]: 'false', [id]: requestId, }, @@ -244,7 +244,7 @@ export class TokensService { headers: { type: sendTransactionHeader, }, - from: dto.operator, + from: dto.signer, to: validPoolId.address, method: methodAbi, params: [ @@ -253,7 +253,7 @@ export class TokensService { encodeHex(dto.data ?? ''), ], } as EthConnectMsgRequest, - this.postOptions(dto.operator, dto.requestId), + this.postOptions(dto.signer, dto.requestId), ), ); @@ -270,7 +270,7 @@ export class TokensService { headers: { type: sendTransactionHeader, }, - from: dto.operator, + from: dto.signer, to: validPoolId.address, method: methodAbi, params: [ @@ -280,7 +280,7 @@ export class TokensService { encodeHex(dto.data ?? ''), ], } as EthConnectMsgRequest, - this.postOptions(dto.operator, dto.requestId), + this.postOptions(dto.signer, dto.requestId), ), ); return { id: response.data.id }; @@ -296,7 +296,7 @@ export class TokensService { headers: { type: sendTransactionHeader, }, - from: dto.operator, + from: dto.signer, to: validPoolId.address, method: methodAbi, params: [ @@ -305,7 +305,7 @@ export class TokensService { encodeHex(dto.data ?? ''), ], } as EthConnectMsgRequest, - this.postOptions(dto.operator, dto.requestId), + this.postOptions(dto.signer, dto.requestId), ), ); return { id: response.data.id }; @@ -345,7 +345,7 @@ class TokenListener implements EventListener { private async getTokenUri( tokenIdx: string, - operator: string, + signer: string, contractAddress: string, ): Promise { const methodABI = standardAbiMap.ERC721WithData.find(method => method.name === 'tokenURI'); @@ -355,7 +355,7 @@ class TokenListener implements EventListener { headers: { type: 'Query', }, - from: operator, + from: signer, to: contractAddress, method: methodABI, params: [tokenIdx], @@ -404,7 +404,7 @@ class TokenListener implements EventListener { type: poolType, poolId: unpackedSub.poolId, amount: poolType === TokenType.FUNGIBLE ? data.value : '1', - operator: event.inputSigner, + signer: event.inputSigner, data: decodedData, timestamp: event.timestamp, rawOutput: data, diff --git a/test/erc20.e2e-spec.ts b/test/erc20.e2e-spec.ts index b1f6cdb..c3c9ae3 100644 --- a/test/erc20.e2e-spec.ts +++ b/test/erc20.e2e-spec.ts @@ -136,7 +136,7 @@ describe('AppController - ERC20/ERC721 (e2e)', () => { const request = { type: TokenType.FUNGIBLE, requestId: REQUEST, - operator: IDENTITY, + signer: IDENTITY, data: `{"tx":${TX}}`, config: { address: CONTRACT_ADDRESS }, name: NAME, @@ -162,7 +162,7 @@ describe('AppController - ERC20/ERC721 (e2e)', () => { const request: TokenPool = { type: TokenType.FUNGIBLE, requestId: REQUEST, - operator: IDENTITY, + signer: IDENTITY, data: `{"tx":${TX}}`, config: { address: CONTRACT_ADDRESS }, name: NAME, @@ -187,7 +187,7 @@ describe('AppController - ERC20/ERC721 (e2e)', () => { const request: TokenPool = { type: TokenType.NONFUNGIBLE, requestId: REQUEST, - operator: IDENTITY, + signer: IDENTITY, data: `{"tx":${TX}}`, config: { address: CONTRACT_ADDRESS }, name: NAME, @@ -212,7 +212,7 @@ describe('AppController - ERC20/ERC721 (e2e)', () => { const request: TokenPool = { type: 'funkible' as TokenType, requestId: REQUEST, - operator: IDENTITY, + signer: IDENTITY, data: `{"tx":${TX}}`, config: { address: CONTRACT_ADDRESS }, name: NAME, @@ -232,7 +232,7 @@ describe('AppController - ERC20/ERC721 (e2e)', () => { it('Mint ERC20 token', async () => { const request: TokenMint = { amount: '20', - operator: IDENTITY, + signer: IDENTITY, poolId: ERC20_POOL_ID, to: '0x123', }; @@ -263,7 +263,7 @@ describe('AppController - ERC20/ERC721 (e2e)', () => { it('Mint ERC721 token', async () => { const request: TokenMint = { tokenIndex: '721', - operator: IDENTITY, + signer: IDENTITY, poolId: ERC721_POOL_ID, to: '0x123', }; @@ -294,7 +294,7 @@ describe('AppController - ERC20/ERC721 (e2e)', () => { it('Transfer ERC20 token', async () => { const request: TokenTransfer = { amount: '20', - operator: IDENTITY, + signer: IDENTITY, poolId: ERC20_POOL_ID, to: '0x123', from: IDENTITY, @@ -328,7 +328,7 @@ describe('AppController - ERC20/ERC721 (e2e)', () => { it('Transfer ERC721 token', async () => { const request: TokenTransfer = { tokenIndex: '721', - operator: IDENTITY, + signer: IDENTITY, poolId: ERC721_POOL_ID, to: '0x123', from: IDENTITY, @@ -362,7 +362,7 @@ describe('AppController - ERC20/ERC721 (e2e)', () => { it('Burn ERC20 token', async () => { const request: TokenBurn = { amount: '20', - operator: IDENTITY, + signer: IDENTITY, poolId: ERC20_POOL_ID, from: IDENTITY, }; @@ -393,7 +393,7 @@ describe('AppController - ERC20/ERC721 (e2e)', () => { it('Burn ERC721 token', async () => { const request: TokenBurn = { tokenIndex: '721', - operator: IDENTITY, + signer: IDENTITY, poolId: ERC721_POOL_ID, from: IDENTITY, }; diff --git a/test/ws.e2e-spec.ts b/test/ws.e2e-spec.ts index 7f7c380..3a088c7 100644 --- a/test/ws.e2e-spec.ts +++ b/test/ws.e2e-spec.ts @@ -213,7 +213,7 @@ describe('WebSocket AppController (e2e)', () => { poolId: ERC20_POOL_ID, to: 'A', amount: '5', - operator: IDENTITY, + signer: IDENTITY, data: 'test', timestamp: '2020-01-01 00:00:00Z', rawOutput: { @@ -288,7 +288,7 @@ describe('WebSocket AppController (e2e)', () => { poolId: ERC721_POOL_ID, to: 'A', amount: '1', - operator: IDENTITY, + signer: IDENTITY, data: 'test', timestamp: '2020-01-01 00:00:00Z', rawOutput: { @@ -336,7 +336,7 @@ describe('WebSocket AppController (e2e)', () => { from: 'A', to: 'B', amount: '5', - operator: IDENTITY, + signer: IDENTITY, data: 'test', timestamp: '2020-01-01 00:00:00Z', rawOutput: { @@ -413,7 +413,7 @@ describe('WebSocket AppController (e2e)', () => { from: 'A', to: 'B', amount: '1', - operator: IDENTITY, + signer: IDENTITY, data: 'test', timestamp: '2020-01-01 00:00:00Z', rawOutput: { @@ -460,7 +460,7 @@ describe('WebSocket AppController (e2e)', () => { poolId: ERC20_POOL_ID, from: 'B', amount: '5', - operator: IDENTITY, + signer: IDENTITY, data: 'test', timestamp: '2020-01-01 00:00:00Z', rawOutput: { @@ -535,7 +535,7 @@ describe('WebSocket AppController (e2e)', () => { poolId: ERC721_POOL_ID, from: 'B', amount: '1', - operator: IDENTITY, + signer: IDENTITY, data: 'test', timestamp: '2020-01-01 00:00:00Z', rawOutput: {