-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add bindings for SampleGoContract (#301)
This contract is only used for testing.
- Loading branch information
Showing
5 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import BN from 'bn.js' | ||
import { Client } from '../client' | ||
import { Contract } from '../contract' | ||
import { Address } from '../address' | ||
import { SampleGoContractNestedEvmRequest } from '../proto/sample_go_contract_pb' | ||
|
||
export class SampleGoContract extends Contract { | ||
static async createAsync(client: Client, callerAddr: Address): Promise<SampleGoContract> { | ||
const contractAddr = await client.getContractAddressAsync('sample-go-contract') | ||
if (!contractAddr) { | ||
throw Error('Failed to resolve contract address') | ||
} | ||
return new SampleGoContract({ contractAddr, callerAddr, client }) | ||
} | ||
|
||
constructor(params: { contractAddr: Address; callerAddr: Address; client: Client }) { | ||
super(params) | ||
} | ||
|
||
testNestedEvmCallsAsync( | ||
innerEmitter: Address, | ||
outerEmitter: Address, | ||
innerEmitterValue: number, | ||
outerEmitterValue: number | ||
): Promise<Uint8Array | void> { | ||
const request = new SampleGoContractNestedEvmRequest() | ||
request.setInnerEmitter(innerEmitter.MarshalPB()) | ||
request.setOuterEmitter(outerEmitter.MarshalPB()) | ||
request.setInnerEmitterValue(innerEmitterValue) | ||
request.setOuterEmitterValue(outerEmitterValue) | ||
|
||
return this.callAsync<void>('TestNestedEvmCalls', request) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
syntax = "proto3"; | ||
|
||
import "proto/loom.proto"; | ||
|
||
message SampleGoContractNestedEvmRequest { | ||
Address inner_emitter = 1; | ||
Address outer_emitter = 2; | ||
uint64 inner_emitter_value = 3; | ||
uint64 outer_emitter_value = 4; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// package: | ||
// file: proto/sample_go_contract.proto | ||
|
||
import * as jspb from "google-protobuf"; | ||
import * as proto_loom_pb from "../proto/loom_pb"; | ||
|
||
export class SampleGoContractNestedEvmRequest extends jspb.Message { | ||
hasInnerEmitter(): boolean; | ||
clearInnerEmitter(): void; | ||
getInnerEmitter(): proto_loom_pb.Address | undefined; | ||
setInnerEmitter(value?: proto_loom_pb.Address): void; | ||
|
||
hasOuterEmitter(): boolean; | ||
clearOuterEmitter(): void; | ||
getOuterEmitter(): proto_loom_pb.Address | undefined; | ||
setOuterEmitter(value?: proto_loom_pb.Address): void; | ||
|
||
getInnerEmitterValue(): number; | ||
setInnerEmitterValue(value: number): void; | ||
|
||
getOuterEmitterValue(): number; | ||
setOuterEmitterValue(value: number): void; | ||
|
||
serializeBinary(): Uint8Array; | ||
toObject(includeInstance?: boolean): SampleGoContractNestedEvmRequest.AsObject; | ||
static toObject(includeInstance: boolean, msg: SampleGoContractNestedEvmRequest): SampleGoContractNestedEvmRequest.AsObject; | ||
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>}; | ||
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>}; | ||
static serializeBinaryToWriter(message: SampleGoContractNestedEvmRequest, writer: jspb.BinaryWriter): void; | ||
static deserializeBinary(bytes: Uint8Array): SampleGoContractNestedEvmRequest; | ||
static deserializeBinaryFromReader(message: SampleGoContractNestedEvmRequest, reader: jspb.BinaryReader): SampleGoContractNestedEvmRequest; | ||
} | ||
|
||
export namespace SampleGoContractNestedEvmRequest { | ||
export type AsObject = { | ||
innerEmitter?: proto_loom_pb.Address.AsObject, | ||
outerEmitter?: proto_loom_pb.Address.AsObject, | ||
innerEmitterValue: number, | ||
outerEmitterValue: number, | ||
} | ||
} | ||
|