import { FlowBridge } from 'flow-bridge';
const bridge = new FlowBridge("https://access-mainnet-beta.onflow.org");
bridge.getEventsForHeightRange(options: {
bottom: number;
top: number;
type: string;
}): Promise<EventsResponse.AsObject>
bridge.executeScript<T extends Type = Void>(options: {
script: string;
args: Type[];
}): Promise<T>
bridge.ping(): Promise<void>
bridge.getLatestBlock(option: {
isSealed: boolean;
}): Promise<BlockResponse.AsObject>
bridge.getBlockById(option: { id: string }): Promise<BlockResponse.AsObject>
bridge.getBlockByHeight(option: {
height: number;
}): Promise<BlockResponse.AsObject>
bridge.getAccountAtLatestBlock(option: {
address: string;
}): Promise<AccountResponse.AsObject>
getTransactionById(option: {
id: string;
}): Promise<TransactionResponse.AsObject>
createTransaction(
params: CreateTransactionParams
): Promise<Transaction>
sendTransaction(
createTransactionParams: CreateTransactionParams
): Promise<string>
interface TransactionSignature {
address: string;
keyId: number;
signature: string;
}
interface TransactionSignatureCreator {
address: string;
keyId: number;
signingFn: (message: string) => Promise<string>;
}
interface ProposalKey {
address: string;
keyId: number;
sequenceNumber: number;
}
interface UnresolvedProposalKey {
address: string;
keyId: number;
}
interface TransactionPayload {
script: string;
arguments: Type[];
referenceBlock: string;
gasLimit: number;
proposalKey: ProposalKey;
payer: string;
authorizers: string[];
}
interface TransactionEnvelope extends TransactionPayload {
payloadSignatures: TransactionSignature[];
}
interface Transaction extends TransactionEnvelope {
envelopeSignatures: TransactionSignature[];
}
interface CreateTransactionPayloadParams {
script: string;
arguments: Type[];
referenceBlock?: string;
gasLimit?: number;
proposalKey: ProposalKey | UnresolvedProposalKey;
payer: string;
authorizers: string[];
}
interface CreateTransactionEnvelopeParams
extends CreateTransactionPayloadParams {
payloadSignatures: (TransactionSignature | TransactionSignatureCreator)[];
}
interface CreateTransactionParams
extends CreateTransactionEnvelopeParams {
envelopeSignatures: (TransactionSignature | TransactionSignatureCreator)[];
}
The Type
are based on the json-cadence syntax. Those are the types implemented right now:
interface Void {
type: "Void";
}
interface Optional {
type: "Optional";
value: Type | null;
}
interface Bool {
type: "Bool";
value: boolean;
}
interface CString {
type: "String";
value: string;
}
interface Address {
type: "Address";
value: `0x${string}`;
}
interface Int {
type: "Int";
value: string;
}
interface Int8 {
type: "Int8";
value: string;
}
interface Int16 {
type: "Int16";
value: string;
}
interface Int32 {
type: "Int32";
value: string;
}
interface Int64 {
type: "Int64";
value: string;
}
interface Int128 {
type: "Int128";
value: string;
}
interface Int256 {
type: "Int256";
value: string;
}
interface Word8 {
type: "Word8";
value: string;
}
interface Word16 {
type: "Word16";
value: string;
}
interface Word32 {
type: "Word32";
value: string;
}
interface Word64 {
type: "Word64";
value: string;
}
interface CArray {
type: "Array";
value: Type[];
}
interface Dictionary {
type: "Dictionary";
value: { key: Type; value: Type }[];
}
protoc \
-I=protos \
--plugin="protoc-gen-ts=./node_modules/.bin/protoc-gen-ts" \
--js_out="import_style=commonjs,binary:lib-web/out_improbable" \
--ts_out="service=grpc-web:lib-web/out_improbable" \
protos/FlowInteractions.proto
protoc \
-I=protos \
--plugin="protoc-gen-ts=./node_modules/.bin/protoc-gen-ts" \
--plugin=protoc-gen-grpc=./node_modules/.bin/grpc_tools_node_protoc_plugin \
--js_out="import_style=commonjs,binary:out_improbable_node" \
--ts_out="service=grpc-node:out_improbable_node" \
--grpc_out="grpc_js:out_improbable_node" \
protos/FlowInteractions.proto
npm run roll
npm run web
npm run transpile
npm start