MCPcopy
hub / github.com/FuelLabs/fuels-ts / getSingleCallInstructions

Function getSingleCallInstructions

packages/program/src/contract-call-script.ts:58–82  ·  view source on GitHub ↗
({
  callDataOffset,
  gasForwardedOffset,
  amountOffset,
  assetIdOffset,
}: CallOpcodeParamsOffset)

Source from the content-addressed store, hash-verified

56//
57// These are arbitrary non-reserved registers, no special meaning
58const getSingleCallInstructions = ({
59 callDataOffset,
60 gasForwardedOffset,
61 amountOffset,
62 assetIdOffset,
63}: CallOpcodeParamsOffset): InstructionSet => {
64 const inst = new InstructionSet(
65 asm.movi(0x10, callDataOffset),
66 asm.movi(0x11, amountOffset),
67 asm.lw(0x11, 0x11, 0),
68 asm.movi(0x12, assetIdOffset)
69 );
70
71 if (gasForwardedOffset) {
72 inst.push(
73 asm.movi(0x13, gasForwardedOffset),
74 asm.lw(0x13, 0x13, 0),
75 asm.call(0x10, 0x11, 0x12, 0x13)
76 );
77 } else {
78 inst.push(asm.call(0x10, 0x11, 0x12, asm.RegId.cgas().to_u8()));
79 }
80
81 return inst;
82};
83// Given a list of contract calls, create the actual opcodes used to call the contract
84function getInstructions(offsets: CallOpcodeParamsOffset[]): Uint8Array {
85 if (!offsets.length) {

Callers 2

getInstructionsFunction · 0.85

Calls 2

pushMethod · 0.95
callMethod · 0.80

Tested by

no test coverage detected