Skip to content

Commit 5195007

Browse files
authored
Merge pull request #1733 from polywrap/nerfzael-bind-imported-env-deps
Added imported env to propertyDeps transform
2 parents c797563 + 8a04f5b commit 5195007

11 files changed

Lines changed: 794 additions & 210 deletions

File tree

packages/schema/bind/src/bindings/assemblyscript/wasm/templates/imported/env-type/index-ts.mustache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {
22
Read,
33
Write,
4+
Box,
45
BigInt,
56
BigNumber,
67
JSON,

packages/schema/bind/src/bindings/rust/transforms/propertyDeps.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
ModuleDefinition,
1010
EnvDefinition,
1111
Abi,
12+
ImportedEnvDefinition,
1213
} from "@polywrap/wrap-manifest-types-js";
1314
import { AbiTransforms } from "@polywrap/schema-parse";
1415

@@ -21,6 +22,7 @@ interface PropertyDep {
2122
interface PropertyDepsState {
2223
abiEnvDefinition?: EnvDefinition;
2324
envDefinition?: EnvDefinition;
25+
importedEnvDefinition?: ImportedEnvDefinition;
2426
objectDefinition?: ObjectDefinition;
2527
moduleDefinition?: ModuleDefinition;
2628
importedModuleDefinition?: ImportedModuleDefinition;
@@ -43,6 +45,11 @@ export function propertyDeps(): AbiTransforms {
4345
state.propertyDeps = [];
4446
return def;
4547
},
48+
ImportedEnvDefinition: (def: ImportedEnvDefinition) => {
49+
state.envDefinition = def;
50+
state.propertyDeps = [];
51+
return def;
52+
},
4653
ObjectDefinition: (def: ObjectDefinition) => {
4754
state.objectDefinition = def;
4855
state.propertyDeps = [];
@@ -124,6 +131,11 @@ export function propertyDeps(): AbiTransforms {
124131
state.envDefinition.type,
125132
state.propertyDeps
126133
);
134+
} else if (state.importedEnvDefinition && state.propertyDeps) {
135+
state.propertyDeps = appendPropertyDep(
136+
state.importedEnvDefinition.type,
137+
state.propertyDeps
138+
);
127139
} else if (state.objectDefinition && state.propertyDeps) {
128140
state.propertyDeps = appendPropertyDep(
129141
state.objectDefinition.type,
@@ -154,6 +166,15 @@ export function propertyDeps(): AbiTransforms {
154166
propertyDeps,
155167
};
156168
},
169+
ImportedEnvDefinition: (def: ImportedEnvDefinition) => {
170+
const propertyDeps = state.propertyDeps;
171+
state.propertyDeps = undefined;
172+
state.importedEnvDefinition = undefined;
173+
return {
174+
...def,
175+
propertyDeps,
176+
};
177+
},
157178
ObjectDefinition: (def: ObjectDefinition) => {
158179
const propertyDeps = state.propertyDeps;
159180
state.propertyDeps = undefined;

packages/test-cases/cases/bind/sanity/input/schema.graphql

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,14 @@ type TestImport_Env @imported(
242242
namespace: "TestImport",
243243
nativeType: "Env"
244244
) {
245-
enviroProp: String!
245+
object: TestImport_AnotherObject!
246+
optObject: TestImport_AnotherObject
247+
objectArray: [TestImport_AnotherObject!]!
248+
optObjectArray: [TestImport_AnotherObject]
249+
en: TestImport_Enum!
250+
optEnum: TestImport_Enum
251+
enumArray: [TestImport_Enum!]!
252+
optEnumArray: [TestImport_Enum]
246253
}
247254

248255
### Imported Envs END ###

packages/test-cases/cases/bind/sanity/output/plugin-py/wrap_info.py

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

packages/test-cases/cases/bind/sanity/output/plugin-rs/wrap.info.rs

Lines changed: 126 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,135 @@ pub fn get_manifest() -> WrapManifest {
113113
"properties": [
114114
{
115115
"kind": 34,
116-
"name": "enviroProp",
116+
"name": "object",
117+
"object": {
118+
"kind": 8192,
119+
"name": "object",
120+
"required": true,
121+
"type": "TestImport_AnotherObject"
122+
},
117123
"required": true,
118-
"scalar": {
119-
"kind": 4,
120-
"name": "enviroProp",
124+
"type": "TestImport_AnotherObject"
125+
},
126+
{
127+
"kind": 34,
128+
"name": "optObject",
129+
"object": {
130+
"kind": 8192,
131+
"name": "optObject",
132+
"type": "TestImport_AnotherObject"
133+
},
134+
"type": "TestImport_AnotherObject"
135+
},
136+
{
137+
"array": {
138+
"item": {
139+
"kind": 8192,
140+
"name": "objectArray",
141+
"required": true,
142+
"type": "TestImport_AnotherObject"
143+
},
144+
"kind": 18,
145+
"name": "objectArray",
146+
"object": {
147+
"kind": 8192,
148+
"name": "objectArray",
149+
"required": true,
150+
"type": "TestImport_AnotherObject"
151+
},
121152
"required": true,
122-
"type": "String"
153+
"type": "[TestImport_AnotherObject]"
123154
},
124-
"type": "String"
155+
"kind": 34,
156+
"name": "objectArray",
157+
"required": true,
158+
"type": "[TestImport_AnotherObject]"
159+
},
160+
{
161+
"array": {
162+
"item": {
163+
"kind": 8192,
164+
"name": "optObjectArray",
165+
"type": "TestImport_AnotherObject"
166+
},
167+
"kind": 18,
168+
"name": "optObjectArray",
169+
"object": {
170+
"kind": 8192,
171+
"name": "optObjectArray",
172+
"type": "TestImport_AnotherObject"
173+
},
174+
"type": "[TestImport_AnotherObject]"
175+
},
176+
"kind": 34,
177+
"name": "optObjectArray",
178+
"type": "[TestImport_AnotherObject]"
179+
},
180+
{
181+
"enum": {
182+
"kind": 16384,
183+
"name": "en",
184+
"required": true,
185+
"type": "TestImport_Enum"
186+
},
187+
"kind": 34,
188+
"name": "en",
189+
"required": true,
190+
"type": "TestImport_Enum"
191+
},
192+
{
193+
"enum": {
194+
"kind": 16384,
195+
"name": "optEnum",
196+
"type": "TestImport_Enum"
197+
},
198+
"kind": 34,
199+
"name": "optEnum",
200+
"type": "TestImport_Enum"
201+
},
202+
{
203+
"array": {
204+
"enum": {
205+
"kind": 16384,
206+
"name": "enumArray",
207+
"required": true,
208+
"type": "TestImport_Enum"
209+
},
210+
"item": {
211+
"kind": 16384,
212+
"name": "enumArray",
213+
"required": true,
214+
"type": "TestImport_Enum"
215+
},
216+
"kind": 18,
217+
"name": "enumArray",
218+
"required": true,
219+
"type": "[TestImport_Enum]"
220+
},
221+
"kind": 34,
222+
"name": "enumArray",
223+
"required": true,
224+
"type": "[TestImport_Enum]"
225+
},
226+
{
227+
"array": {
228+
"enum": {
229+
"kind": 16384,
230+
"name": "optEnumArray",
231+
"type": "TestImport_Enum"
232+
},
233+
"item": {
234+
"kind": 16384,
235+
"name": "optEnumArray",
236+
"type": "TestImport_Enum"
237+
},
238+
"kind": 18,
239+
"name": "optEnumArray",
240+
"type": "[TestImport_Enum]"
241+
},
242+
"kind": 34,
243+
"name": "optEnumArray",
244+
"type": "[TestImport_Enum]"
125245
}
126246
],
127247
"type": "TestImport_Env",

packages/test-cases/cases/bind/sanity/output/plugin-ts/wrap.info.ts

Lines changed: 126 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,15 +111,135 @@ export const manifest: WrapManifest = {
111111
"properties": [
112112
{
113113
"kind": 34,
114-
"name": "enviroProp",
114+
"name": "object",
115+
"object": {
116+
"kind": 8192,
117+
"name": "object",
118+
"required": true,
119+
"type": "TestImport_AnotherObject"
120+
},
115121
"required": true,
116-
"scalar": {
117-
"kind": 4,
118-
"name": "enviroProp",
122+
"type": "TestImport_AnotherObject"
123+
},
124+
{
125+
"kind": 34,
126+
"name": "optObject",
127+
"object": {
128+
"kind": 8192,
129+
"name": "optObject",
130+
"type": "TestImport_AnotherObject"
131+
},
132+
"type": "TestImport_AnotherObject"
133+
},
134+
{
135+
"array": {
136+
"item": {
137+
"kind": 8192,
138+
"name": "objectArray",
139+
"required": true,
140+
"type": "TestImport_AnotherObject"
141+
},
142+
"kind": 18,
143+
"name": "objectArray",
144+
"object": {
145+
"kind": 8192,
146+
"name": "objectArray",
147+
"required": true,
148+
"type": "TestImport_AnotherObject"
149+
},
119150
"required": true,
120-
"type": "String"
151+
"type": "[TestImport_AnotherObject]"
121152
},
122-
"type": "String"
153+
"kind": 34,
154+
"name": "objectArray",
155+
"required": true,
156+
"type": "[TestImport_AnotherObject]"
157+
},
158+
{
159+
"array": {
160+
"item": {
161+
"kind": 8192,
162+
"name": "optObjectArray",
163+
"type": "TestImport_AnotherObject"
164+
},
165+
"kind": 18,
166+
"name": "optObjectArray",
167+
"object": {
168+
"kind": 8192,
169+
"name": "optObjectArray",
170+
"type": "TestImport_AnotherObject"
171+
},
172+
"type": "[TestImport_AnotherObject]"
173+
},
174+
"kind": 34,
175+
"name": "optObjectArray",
176+
"type": "[TestImport_AnotherObject]"
177+
},
178+
{
179+
"enum": {
180+
"kind": 16384,
181+
"name": "en",
182+
"required": true,
183+
"type": "TestImport_Enum"
184+
},
185+
"kind": 34,
186+
"name": "en",
187+
"required": true,
188+
"type": "TestImport_Enum"
189+
},
190+
{
191+
"enum": {
192+
"kind": 16384,
193+
"name": "optEnum",
194+
"type": "TestImport_Enum"
195+
},
196+
"kind": 34,
197+
"name": "optEnum",
198+
"type": "TestImport_Enum"
199+
},
200+
{
201+
"array": {
202+
"enum": {
203+
"kind": 16384,
204+
"name": "enumArray",
205+
"required": true,
206+
"type": "TestImport_Enum"
207+
},
208+
"item": {
209+
"kind": 16384,
210+
"name": "enumArray",
211+
"required": true,
212+
"type": "TestImport_Enum"
213+
},
214+
"kind": 18,
215+
"name": "enumArray",
216+
"required": true,
217+
"type": "[TestImport_Enum]"
218+
},
219+
"kind": 34,
220+
"name": "enumArray",
221+
"required": true,
222+
"type": "[TestImport_Enum]"
223+
},
224+
{
225+
"array": {
226+
"enum": {
227+
"kind": 16384,
228+
"name": "optEnumArray",
229+
"type": "TestImport_Enum"
230+
},
231+
"item": {
232+
"kind": 16384,
233+
"name": "optEnumArray",
234+
"type": "TestImport_Enum"
235+
},
236+
"kind": 18,
237+
"name": "optEnumArray",
238+
"type": "[TestImport_Enum]"
239+
},
240+
"kind": 34,
241+
"name": "optEnumArray",
242+
"type": "[TestImport_Enum]"
123243
}
124244
],
125245
"type": "TestImport_Env",

packages/test-cases/cases/bind/sanity/output/wasm-as/imported/TestImport_Env/index.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {
22
Read,
33
Write,
4+
Box,
45
BigInt,
56
BigNumber,
67
JSON,
@@ -18,7 +19,14 @@ export class TestImport_Env {
1819

1920
public static uri: string = "testimport.uri.eth";
2021

21-
enviroProp: string;
22+
object: Types.TestImport_AnotherObject;
23+
optObject: Types.TestImport_AnotherObject | null;
24+
objectArray: Array<Types.TestImport_AnotherObject>;
25+
optObjectArray: Array<Types.TestImport_AnotherObject | null> | null;
26+
en: Types.TestImport_Enum;
27+
optEnum: Box<Types.TestImport_Enum> | null;
28+
enumArray: Array<Types.TestImport_Enum>;
29+
optEnumArray: Array<Box<Types.TestImport_Enum> | null> | null;
2230

2331
static toBuffer(type: TestImport_Env): ArrayBuffer {
2432
return serializeTestImport_Env(type);

0 commit comments

Comments
 (0)