const ethereumPackage: IWrapPackage = loader.load("ens/ethereum.eth");
const uniswapPackage: IWrapPackage = loader.load("ens/uniswap.eth");
const ethereumWrapper: IWrapInstance = ethereumPackage.createWrapper();
const uniswapWrapper: IWrapInstance = uniswapPackage.createWrapper();
const provider: IEthereumProvider = await EthereumProvider__factory.fromWrapper(ethereumWrapper, { rpcUrl });
const uniswap: IUniswap = await Uniswap__factory.fromWrapper(uniswapWrapper, { provider });
await uniswap.swap("eth", "dai", 10);
#import { IEthereumProvider } into Ethereum from "@ethereum-interface"
#import { ILogger } into Diagnostics from "diagnostics-interface"
#import { IClient, @require } into Polywrap from "polywrap-interface"
module {
constructor(
Polywrap.@require(
uris: [
"diagnostics.eth"
]
)
client: Polywrap.IClient!
http: Http!
): void
}
type Http {
get(env: Env): String
}
type Test {
constructor(logger: Diagnostics.ILogger!): void
run: String
}
type Test2 {
constructor(loader: Polywrap.IPackageLoader!): void
run: String
}
type Uniswap {
constructor(
Polywrap.@require(
uris: [
"http.eth"
]
)
client: Polywrap.PolywrapClient!
): void
swap(from: String!, to: String!, amount: Uint!): ITransaction!;
}
interface ITransaction {
id: String!
wait(confirmations: Uint!): Receipt
}
type Receipt {
blockNumber: String!;
}