runMethod method

  1. @override
Future<({int gasUsed, TupleReader stack})> runMethod(
  1. InternalAddress address,
  2. String methodName, [
  3. List<TupleItem> stack = const <TupleItem>[]
])

Returns the gas used and the stack after the get method invocation as a record, wrapped in a Future:

Future<({
  int gasUsed,
  TupleReader stack,
})>

Throws 'Unable to execute...' if the exit code != 0

Implementation

@override
Future<({int gasUsed, TupleReader stack})> runMethod(
    InternalAddress address, String methodName,
    [List<TupleItem> stack = const <TupleItem>[]]) async {

  if (methodName == 'get_wallet_address' && stack[0] is TiSlice) {
    try {
      final jettonWalletAddress = await _client.v1JettonAddrStrAddressGet(
            addrStr: 'get_wallet_address',
            ownerAddress: (stack[0] as TiSlice).cell.beginParse().loadInternalAddress().toString(),
          );

      return (
        gasUsed: 0,
        stack: TupleReader([
          TiSlice(beginCell()
              .storeAddress(InternalAddress.parse(jettonWalletAddress.body?.address ?? ''))
              .endCell())
        ]),
      );
    } catch (e) {
      // ignored
    }
  }

  return super.runMethod(address, methodName, stack);
}