Skip to content

Commit

Permalink
Rename "abi" parameter to "methods"
Browse files Browse the repository at this point in the history
This parameter is not the full ABI, but a list of methods encoded in
ABI format.

Signed-off-by: Andrew Richardson <andrew.richardson@kaleido.io>
  • Loading branch information
awrichar committed Jan 5, 2023
1 parent c51742b commit 1866f88
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/tokens/tokens.interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ export class TokenInterface {

@ApiProperty({ isArray: true })
@IsDefined()
abi: IAbiMethod[];
methods: IAbiMethod[];
}

export class CheckInterfaceRequest extends TokenInterface {
Expand Down
18 changes: 9 additions & 9 deletions src/tokens/tokens.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,14 +320,14 @@ export class TokensService {

checkInterface(dto: CheckInterfaceRequest): CheckInterfaceResponse {
const wrapMethods = (methods: IAbiMethod[]): TokenInterface => {
return { format: InterfaceFormat.ABI, abi: methods };
return { format: InterfaceFormat.ABI, methods };
};

return {
approval: wrapMethods(this.mapper.getAllMethods(dto.abi, DynamicMethods.approval)),
burn: wrapMethods(this.mapper.getAllMethods(dto.abi, DynamicMethods.burn)),
mint: wrapMethods(this.mapper.getAllMethods(dto.abi, DynamicMethods.mint)),
transfer: wrapMethods(this.mapper.getAllMethods(dto.abi, DynamicMethods.transfer)),
approval: wrapMethods(this.mapper.getAllMethods(dto.methods, DynamicMethods.approval)),
burn: wrapMethods(this.mapper.getAllMethods(dto.methods, DynamicMethods.burn)),
mint: wrapMethods(this.mapper.getAllMethods(dto.methods, DynamicMethods.mint)),
transfer: wrapMethods(this.mapper.getAllMethods(dto.methods, DynamicMethods.transfer)),
};
}

Expand All @@ -339,7 +339,7 @@ export class TokensService {
async mint(dto: TokenMint): Promise<AsyncResponse> {
const poolLocator = unpackPoolLocator(dto.poolLocator);
const address = poolLocator.address ?? (await this.getContractAddress());
const abi = dto.interface?.abi || (await this.getAbiForMint(address, dto));
const abi = dto.interface?.methods || (await this.getAbiForMint(address, dto));
const { method, params } = this.mapper.getMethodAndParams(abi, poolLocator, 'mint', dto);
const response = await this.blockchain.sendTransaction(
dto.signer,
Expand All @@ -354,7 +354,7 @@ export class TokensService {
async transfer(dto: TokenTransfer): Promise<AsyncResponse> {
const poolLocator = unpackPoolLocator(dto.poolLocator);
const address = poolLocator.address ?? (await this.getContractAddress());
const abi = dto.interface?.abi || this.mapper.getAbi();
const abi = dto.interface?.methods || this.mapper.getAbi();
const { method, params } = this.mapper.getMethodAndParams(abi, poolLocator, 'transfer', dto);
const response = await this.blockchain.sendTransaction(
dto.signer,
Expand All @@ -369,7 +369,7 @@ export class TokensService {
async burn(dto: TokenBurn): Promise<AsyncResponse> {
const poolLocator = unpackPoolLocator(dto.poolLocator);
const address = poolLocator.address ?? (await this.getContractAddress());
const abi = dto.interface?.abi || this.mapper.getAbi();
const abi = dto.interface?.methods || this.mapper.getAbi();
const { method, params } = this.mapper.getMethodAndParams(abi, poolLocator, 'burn', dto);
const response = await this.blockchain.sendTransaction(
dto.signer,
Expand All @@ -385,7 +385,7 @@ export class TokensService {
async approval(dto: TokenApproval): Promise<AsyncResponse> {
const poolLocator = unpackPoolLocator(dto.poolLocator);
const address = poolLocator.address ?? (await this.getContractAddress());
const abi = dto.interface?.abi || this.mapper.getAbi();
const abi = dto.interface?.methods || this.mapper.getAbi();
const { method, params } = this.mapper.getMethodAndParams(abi, poolLocator, 'approval', dto);
const response = await this.blockchain.sendTransaction(
dto.signer,
Expand Down
10 changes: 5 additions & 5 deletions test/suites/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -365,32 +365,32 @@ export default (context: TestContext) => {
const request: CheckInterfaceRequest = {
poolLocator: 'F1',
format: InterfaceFormat.ABI,
abi: ERC1155MixedFungibleAbi,
methods: ERC1155MixedFungibleAbi,
};

const response: CheckInterfaceResponse = {
approval: {
format: InterfaceFormat.ABI,
abi: [
methods: [
...ERC1155MixedFungibleAbi.filter(m => m.name === 'setApprovalForAllWithData'),
...ERC1155MixedFungibleAbi.filter(m => m.name === 'setApprovalForAll'),
],
},
burn: {
format: InterfaceFormat.ABI,
abi: ERC1155MixedFungibleAbi.filter(m => m.name === 'burn'),
methods: ERC1155MixedFungibleAbi.filter(m => m.name === 'burn'),
},
mint: {
format: InterfaceFormat.ABI,
abi: [
methods: [
...ERC1155MixedFungibleAbi.filter(m => m.name === 'mintFungible'),
...ERC1155MixedFungibleAbi.filter(m => m.name === 'mintNonFungibleWithURI'),
...ERC1155MixedFungibleAbi.filter(m => m.name === 'mintNonFungible'),
],
},
transfer: {
format: InterfaceFormat.ABI,
abi: ERC1155MixedFungibleAbi.filter(m => m.name === 'safeTransferFrom'),
methods: ERC1155MixedFungibleAbi.filter(m => m.name === 'safeTransferFrom'),
},
};

Expand Down

0 comments on commit 1866f88

Please sign in to comment.