Your code for creating the WAN IP instance is not correct. See this post for the proper syntax.
Here is some p-code to help you understand the syntax/flow:
let basePath = 'InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection';
// Clear everything out
declare(basePath + '.[]', null, {path: 0});
// Create the first interface, or it *WILL* be removed. Fill in with the appropriate values
declare(basePath + '.[Enable:true,Name:MANAGEMENT,AddressingType:DHCP, ConnectionType:IP_ROUTED]', {path: 1}, {path: 1});
// Create the second interface
declare(basePath + '.[Enable:true,Name:INTERNET_DHCP,AddressingType:DHCP, ConnectionType:IP_ROUTED]', {path: 1}, {path: 1});