UNPKG

@gear-js/api

Version:

A JavaScript library that provides functionality to connect GEAR Component APIs.

207 lines (204 loc) 5.66 kB
'use strict'; const SOURCE = { name: 'source', type: 'H256', }; const DESTINATION = { name: 'dest', type: 'H256', }; const PAYLOAD = { name: 'payload', type: 'Vec<u8>', }; const VALUE = { name: 'value', type: 'u128', }; const ALLOW_OTHER_PANICS = { name: 'allow_other_panics', type: 'bool', }; const CODE = { name: 'code', type: 'Vec<u8>', }; const CODE_ID = { name: 'code_id', type: 'H256', }; const PROGRAM_ID = { name: 'program_id', type: 'H256', }; const AT = { name: 'at', type: 'Option<BlockHash>', isOptional: true, }; const calculateInitUploadGas = { description: 'Calculate gas for Init message using upload_program extrinsic', params: [SOURCE, CODE, PAYLOAD, VALUE, ALLOW_OTHER_PANICS], type: 'GasInfo', }; const calculateInitCreateGas = { description: 'Calculate gas for Init message using create_program extrinsic', params: [SOURCE, CODE_ID, PAYLOAD, VALUE, ALLOW_OTHER_PANICS], type: 'GasInfo', }; const calculateHandleGas = { description: 'Calculate gas for Handle message', params: [SOURCE, DESTINATION, PAYLOAD, VALUE, ALLOW_OTHER_PANICS], type: 'GasInfo', }; const calculateReplyGas = { description: 'Calculate gas for Reply message', params: [ SOURCE, { name: 'message_id', type: 'H256', }, PAYLOAD, VALUE, ALLOW_OTHER_PANICS, ], type: 'GasInfo', }; const GEAR_RPC_METHODS = { calculateInitUploadGas, calculateInitCreateGas, calculateHandleGas, calculateReplyGas, calculateGasForUpload: calculateInitUploadGas, calculateGasForCreate: calculateInitCreateGas, calculateGasForHandle: calculateHandleGas, calculateGasForReply: calculateReplyGas, readMetahash: { description: "Read program's metahash", params: [PROGRAM_ID, AT], type: 'H256', deprecated: 'Deprecated in favor of Sails', }, readState: { description: "Call program's `state` function", params: [PROGRAM_ID, PAYLOAD, AT], type: 'Bytes', deprecated: 'Deprecated in favor of `calculateReplyForHandle`', }, readStateUsingWasm: { description: "Read program's state using wasm", deprecated: 'Deprecated in favor of `calculateReplyForHandle`', params: [ PROGRAM_ID, PAYLOAD, { name: 'fn_name', type: 'Bytes' }, { name: 'wasm', type: 'Bytes' }, { name: 'argument', type: 'Option<Bytes>' }, AT, ], type: 'Bytes', }, readStateBatch: { description: "Read program's state using batch", deprecated: 'Deprecated in favor of `calculateReplyForHandle`', params: [{ name: 'batch_id_payload', type: 'Vec<(H256, Bytes)>' }, AT], type: 'Vec<Bytes>', }, readStateUsingWasmBatch: { description: "Read program's state using wasm batch", deprecated: 'Deprecated in favor of `calculateReplyForHandle`', params: [ { name: 'batch_id_payload', type: 'Vec<(H256, Bytes)>' }, { name: 'fn_name', type: 'Bytes' }, { name: 'wasm', type: 'Bytes' }, { name: 'argument', type: 'Option<Bytes>' }, AT, ], type: 'Vec<Bytes>', }, calculateReplyForHandle: { description: 'Calculate reply for Handle message', params: [ { name: 'origin', type: 'H256', }, DESTINATION, PAYLOAD, { name: 'gasLimit', type: 'u64', }, VALUE, AT, ], type: 'ReplyInfo', }, subscribeProgramStateChanges: { description: 'Subscribe to program state changes', params: [ { name: 'program_ids', type: 'Option<Vec<H256>>', }, ], pubsub: ['subscribeProgramStateChanges', 'subscribeProgramStateChanges', 'unsubscribeProgramStateChanges'], type: 'ProgramStateChange', }, subscribeUserMessageSent: { description: 'Subscribe to user message sent events', params: [ { name: 'filter', type: 'UserMsgFilter', }, ], type: 'UserMessageSentJson', pubsub: ['subscribeUserMessageSent', 'subscribeUserMessageSent', 'unsubscribeUserMessageSent'], }, }; const GEAR_BUILTIN_RPC_METHODS = { queryId: { description: 'Query builtin ID', params: [ { name: 'builtin_id', type: 'u64', }, ], type: 'H256', }, }; const GEAR_ETH_BRIDGE_RPC_METHODS = { merkleProof: { description: 'Query merkle proof for a message', params: [ { name: 'hash', type: 'H256', }, AT, ], type: 'Proof', }, }; const STAKING_REWARDS_METHODS = { inflationInfo: { description: 'Query inflation info', params: [], type: 'Bytes', }, }; const RUNTIME_METHODS = { wasmBlobVersion: { description: 'Returns the version of the WASM blob in storage.', params: [], type: 'String', }, }; exports.GEAR_BUILTIN_RPC_METHODS = GEAR_BUILTIN_RPC_METHODS; exports.GEAR_ETH_BRIDGE_RPC_METHODS = GEAR_ETH_BRIDGE_RPC_METHODS; exports.GEAR_RPC_METHODS = GEAR_RPC_METHODS; exports.RUNTIME_METHODS = RUNTIME_METHODS; exports.STAKING_REWARDS_METHODS = STAKING_REWARDS_METHODS;