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 f492094 commit ba1a628
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/tokens/tokens.interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,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 @@ -392,15 +392,15 @@ export class TokensService {
}

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

const methods = poolLocator.type === TokenType.FUNGIBLE ? ERC20Methods : ERC721Methods;
return {
approval: wrapMethods(this.mapper.getAllMethods(dto.abi, methods.approval)),
burn: wrapMethods(this.mapper.getAllMethods(dto.abi, methods.burn)),
mint: wrapMethods(this.mapper.getAllMethods(dto.abi, methods.mint)),
transfer: wrapMethods(this.mapper.getAllMethods(dto.abi, methods.transfer)),
approval: wrapMethods(this.mapper.getAllMethods(dto.methods, methods.approval)),
burn: wrapMethods(this.mapper.getAllMethods(dto.methods, methods.burn)),
mint: wrapMethods(this.mapper.getAllMethods(dto.methods, methods.mint)),
transfer: wrapMethods(this.mapper.getAllMethods(dto.methods, methods.transfer)),
};
}

Expand All @@ -416,7 +416,7 @@ export class TokensService {
throw new BadRequestException('Invalid pool locator');
}

const abi = dto.interface?.abi || (await this.getAbiForMint(ctx, poolLocator, dto));
const abi = dto.interface?.methods || (await this.getAbiForMint(ctx, poolLocator, dto));
const { method, params } = this.mapper.getMethodAndParams(
abi,
poolLocator.type === TokenType.FUNGIBLE,
Expand All @@ -440,7 +440,7 @@ export class TokensService {
throw new BadRequestException('Invalid pool locator');
}

const abi = dto.interface?.abi || this.mapper.getAbi(poolLocator.schema);
const abi = dto.interface?.methods || this.mapper.getAbi(poolLocator.schema);
const { method, params } = this.mapper.getMethodAndParams(
abi,
poolLocator.type === TokenType.FUNGIBLE,
Expand All @@ -464,7 +464,7 @@ export class TokensService {
throw new BadRequestException('Invalid pool locator');
}

const abi = dto.interface?.abi || this.mapper.getAbi(poolLocator.schema);
const abi = dto.interface?.methods || this.mapper.getAbi(poolLocator.schema);
const { method, params } = this.mapper.getMethodAndParams(
abi,
poolLocator.type === TokenType.FUNGIBLE,
Expand All @@ -488,7 +488,7 @@ export class TokensService {
throw new BadRequestException('Invalid pool locator');
}

const abi = dto.interface?.abi || this.mapper.getAbi(poolLocator.schema);
const abi = dto.interface?.methods || this.mapper.getAbi(poolLocator.schema);
const { method, params } = this.mapper.getMethodAndParams(
abi,
poolLocator.type === TokenType.FUNGIBLE,
Expand Down
14 changes: 7 additions & 7 deletions test/suites/erc20.ts
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ export default (context: TestContext) => {
from: IDENTITY,
interface: {
format: InterfaceFormat.ABI,
abi: burnMethods,
methods: burnMethods,
},
};

Expand Down Expand Up @@ -634,7 +634,7 @@ export default (context: TestContext) => {
from: '0x2',
interface: {
format: InterfaceFormat.ABI,
abi: burnMethods,
methods: burnMethods,
},
};

Expand Down Expand Up @@ -665,27 +665,27 @@ export default (context: TestContext) => {
const request: CheckInterfaceRequest = {
poolLocator: ERC20_NO_DATA_POOL_ID,
format: InterfaceFormat.ABI,
abi: ERC20NoDataABI.abi,
methods: ERC20NoDataABI.abi,
};

const response: CheckInterfaceResponse = {
approval: {
format: InterfaceFormat.ABI,
abi: ERC20NoDataABI.abi.filter(m => m.name === APPROVE_NO_DATA),
methods: ERC20NoDataABI.abi.filter(m => m.name === APPROVE_NO_DATA),
},
burn: {
format: InterfaceFormat.ABI,
abi: ERC20NoDataABI.abi.filter(
methods: ERC20NoDataABI.abi.filter(
m => m.name === BURN_NO_DATA || m.name === BURN_FROM_NO_DATA,
),
},
mint: {
format: InterfaceFormat.ABI,
abi: ERC20NoDataABI.abi.filter(m => m.name === MINT_NO_DATA),
methods: ERC20NoDataABI.abi.filter(m => m.name === MINT_NO_DATA),
},
transfer: {
format: InterfaceFormat.ABI,
abi: [
methods: [
...ERC20NoDataABI.abi.filter(m => m.name === TRANSFER_NO_DATA),
...ERC20NoDataABI.abi.filter(m => m.name === TRANSFER_FROM_NO_DATA),
],
Expand Down
12 changes: 6 additions & 6 deletions test/suites/erc721.ts
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ export default (context: TestContext) => {
to: '0x123',
interface: {
format: InterfaceFormat.ABI,
abi: [safeMintAutoIndex],
methods: [safeMintAutoIndex],
},
};

Expand Down Expand Up @@ -575,28 +575,28 @@ export default (context: TestContext) => {
const request: CheckInterfaceRequest = {
poolLocator: ERC721_NO_DATA_POOL_ID,
format: InterfaceFormat.ABI,
abi: ERC721NoDataABI.abi,
methods: ERC721NoDataABI.abi,
};

const response: CheckInterfaceResponse = {
approval: {
format: InterfaceFormat.ABI,
abi: [
methods: [
...ERC721NoDataABI.abi.filter(m => m.name === APPROVE_NO_DATA),
...ERC721NoDataABI.abi.filter(m => m.name === APPROVE_FOR_ALL_NO_DATA),
],
},
burn: {
format: InterfaceFormat.ABI,
abi: ERC721NoDataABI.abi.filter(m => m.name === BURN_NO_DATA),
methods: ERC721NoDataABI.abi.filter(m => m.name === BURN_NO_DATA),
},
mint: {
format: InterfaceFormat.ABI,
abi: ERC721NoDataABI.abi.filter(m => m.name === MINT_NO_DATA),
methods: ERC721NoDataABI.abi.filter(m => m.name === MINT_NO_DATA),
},
transfer: {
format: InterfaceFormat.ABI,
abi: [
methods: [
...ERC721NoDataABI.abi.filter(
m => m.name === TRANSFER_NO_DATA && m.inputs.length === 4,
),
Expand Down

0 comments on commit ba1a628

Please sign in to comment.