Skip to content

Commit a263ad2

Browse files
committed
abi: Fix validating call handlers for functions with tuple params (#500)
1 parent 8d59839 commit a263ad2

File tree

7 files changed

+82
-1
lines changed

7 files changed

+82
-1
lines changed

src/abi.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ module.exports = class ABI {
108108
const name = entry.get('name', '<default>')
109109
const inputs = entry
110110
.get('inputs', immutable.List())
111-
.map(input => input.get('type'))
111+
.map(input => buildSignatureParameter(input))
112112

113113
return `${name}(${inputs.join(',')})`
114114
})

tests/cli/validation.test.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@ describe('Validation', () => {
3939
exitCode: 1,
4040
},
4141
)
42+
cliTest(
43+
'Call handler with tuple',
44+
['codegen', '--skip-migrations'],
45+
'validation/call-handler-with-tuple',
46+
{
47+
exitCode: 0,
48+
},
49+
)
4250
cliTest(
4351
'Missing entity "id" field',
4452
['codegen', '--skip-migrations'],
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
- Load subgraph from subgraph.yaml
2+
✔ Load subgraph from subgraph.yaml
3+
- Load contract ABIs
4+
Load contract ABI from Abi.json
5+
- Load contract ABIs
6+
✔ Load contract ABIs
7+
- Generate types for contract ABIs
8+
Generate types for contract ABI: ExampleContract (Abi.json)
9+
- Generate types for contract ABIs
10+
Write types to generated/ExampleSubgraph/ExampleContract.ts
11+
- Generate types for contract ABIs
12+
✔ Generate types for contract ABIs
13+
- Generate types for data source templates
14+
✔ Generate types for data source templates
15+
- Load data source template ABIs
16+
✔ Load data source template ABIs
17+
- Generate types for data source template ABIs
18+
✔ Generate types for data source template ABIs
19+
- Load GraphQL schema from schema.graphql
20+
✔ Load GraphQL schema from schema.graphql
21+
- Generate types for GraphQL schema
22+
Write types to generated/schema.ts
23+
- Generate types for GraphQL schema
24+
✔ Generate types for GraphQL schema
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
[
2+
{
3+
"constant": false,
4+
"inputs": [
5+
{ "name": "", "type": "uint256" },
6+
{
7+
"type": "tuple",
8+
"components": [
9+
{ "type": "bytes32" },
10+
{ "type": "bytes32" },
11+
{ "type": "uint256" }
12+
]
13+
},
14+
{
15+
"type": "bool"
16+
}
17+
],
18+
"name": "doSomething",
19+
"outputs": [],
20+
"payable": false,
21+
"stateMutability": "nonpayable",
22+
"type": "function"
23+
}
24+
]

tests/cli/validation/call-handler-with-tuple/mapping.ts

Whitespace-only changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
type MyEntity @entity {
2+
id: ID!
3+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
specVersion: 0.0.2
2+
schema:
3+
file: ./schema.graphql
4+
dataSources:
5+
- kind: ethereum/contract
6+
name: ExampleSubgraph
7+
source:
8+
address: '22843e74c59580b3eaf6c233fa67d8b7c561a835'
9+
abi: ExampleContract
10+
mapping:
11+
kind: ethereum/events
12+
apiVersion: 0.0.1
13+
language: wasm/assemblyscript
14+
file: ./mapping.ts
15+
entities:
16+
- ExampleEntity
17+
abis:
18+
- name: ExampleContract
19+
file: ./Abi.json
20+
callHandlers:
21+
- function: doSomething(uint256,(bytes32,bytes32,uint256),bool)
22+
handler: handleDoSomething

0 commit comments

Comments
 (0)