Skip to content

Commit

Permalink
add optional config, change owner -> signer
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Shorsher <alex.shorsher@kaleido.io>
  • Loading branch information
shorsher authored and awrichar committed Feb 23, 2022
1 parent ba4e579 commit fcac90f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
8 changes: 7 additions & 1 deletion src/tokens/tokens.interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ const requestIdDescription =
'If none is provided, one will be assigned and returned in the 202 response.';
const poolConfigDescription =
'Optional configuration info for the token pool. Reserved for future use.';
const approvalConfigDescription =
'Optional configuration info for the token approval. Reserved for future use.';

export class TokenPool {
@ApiProperty({ enum: TokenType })
Expand Down Expand Up @@ -111,7 +113,7 @@ export class TokenApproval {

@ApiProperty()
@IsNotEmpty()
owner: string;
signer: string;

@ApiProperty()
@IsNotEmpty()
Expand All @@ -128,6 +130,10 @@ export class TokenApproval {
@ApiProperty()
@IsOptional()
data?: string;

@ApiProperty({ description: approvalConfigDescription })
@IsOptional()
config?: any;
}

export class BlockchainTransaction {
Expand Down
7 changes: 3 additions & 4 deletions src/tokens/tokens.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,8 @@ export class TokensService {
this.stream.id,
approvalForAllEvent,
packSubscriptionName(this.topic, dto.poolId, approvalForAllEvent),
// Block number is 0 because it is important to receive all approval events,
// so existing approvals will be reflected in the newly created pool
'0',
),
]);
Expand Down Expand Up @@ -295,7 +297,7 @@ export class TokensService {
approved: dto.approved,
data: encodeHex(dto.data ?? ''),
},
this.postOptions(dto.owner, dto.requestId),
this.postOptions(dto.signer, dto.requestId),
),
);
return { id: response.data.id };
Expand Down Expand Up @@ -377,9 +379,6 @@ class TokenListener implements EventListener {
process(msg);
}
break;
case approvalForAllEventSignature:
process(this.transformTokenCreateEvent(subName, event));
break;
default:
this.logger.error(`Unknown event signature: ${event.signature}`);
return undefined;
Expand Down
9 changes: 1 addition & 8 deletions test/app.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ describe('AppController (e2e)', () => {
it('Token approval', async () => {
const request: TokenApproval = {
poolId: 'F1',
owner: IDENTITY,
signer: IDENTITY,
operator: '2',
approved: true,
};
Expand Down Expand Up @@ -768,13 +768,6 @@ describe('AppController (e2e)', () => {
name: TOPIC + ':N1',
});

http.get = jest.fn(
() =>
new FakeObservable(<EthConnectReturn>{
output: 'firefly://token/{id}',
}),
);

await server
.ws('/api/ws')
.exec(() => {
Expand Down

0 comments on commit fcac90f

Please sign in to comment.