local method
Future<PactResponse>
local({
- required PactCommand command,
- String? chainId,
- String? nodeUrl,
- String? networkId,
- bool preflight = true,
- bool signatureValidation = true,
- String? url,
override
Send a local pact command to the node
The command
is the pact command to execute dirtily.
The chainId
is the chainId to execute the command on. It is required if url
is not provided.
The nodeUrl
and the networkId
are used to override the defaults set
by setNodeUrl and setNetworkId when building the url for the pact api.
The url
is the full node url, example: https://api.chainweb.com/chainweb/0.0/testnet01/chain/0/pact/api/v1
If url
is provided, the chainId
is not required.
The preflight
is a boolean to enable/disable preflight.
If enabled, the command will be executed in a simulated transaction as close to send as possible.
The signatureValidation
is a boolean to enable/disable signature validation in the local call.
Implementation
@override
Future<PactResponse> local({
required PactCommand command,
String? chainId,
String? nodeUrl,
String? networkId,
bool preflight = true,
bool signatureValidation = true,
String? url,
}) async {
Uri uri = url == null
? buildEndpoint(
endpoint: PactApiV1Endpoints.local,
chainId: chainId!,
nodeUrl: nodeUrl,
networkId: networkId,
queryParameters: {
'preflight': preflight,
'signatureValidation': signatureValidation,
},
)
: buildEndpoint(
endpoint: PactApiV1Endpoints.local,
url: url,
queryParameters: {
'preflight': preflight,
'signatureValidation': signatureValidation,
},
);
// print(uri.toString());
// print('local');
// print(jsonEncode(command));
http.Response response = await http.post(
uri,
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
},
body: jsonEncode(command),
);
try {
return PactResponse.fromJson(
jsonDecode(
response.body,
),
);
} catch (e) {
throw PactApiError(
error: response.body,
);
}
}