Skip to content

Commit

Permalink
Merge pull request #4 from lacchain/feature/ethers-6
Browse files Browse the repository at this point in the history
Feature/ethers 6
  • Loading branch information
edumar111 authored Dec 21, 2023
2 parents 1036a5c + 39c5fe3 commit f0b07a2
Show file tree
Hide file tree
Showing 841 changed files with 44,919 additions and 4,261 deletions.
Binary file added .DS_Store
Binary file not shown.
3 changes: 3 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
RPC_URL = 'http://35.185.112.219:80'
NODE_ADDRESS = '0xad730de8c4bfc3d845f7ce851bcf2ea17c049585'
TRUSTED_FORWARDER = '0xa4B5eE2906090ce2cDbf5dfff944db26f397037D'
5 changes: 0 additions & 5 deletions .prettierrc

This file was deleted.

8 changes: 8 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"semi": true,
"singleQuote": true,
"printWidth": 80,
"tabWidth": 2,
"trailingComma": "all",
"arrowParens": "always"
}
20 changes: 20 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "ts-node",
"type": "node",
"request": "launch",
"args": [
"${relativeFile}"
],
"runtimeArgs": [
"-r",
"ts-node/register"
],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"internalConsoleOptions": "openOnSessionStart"
}
]
}
64 changes: 47 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
## LAC-NET Gas Model provider for ether.js

This repository contains the GasModelProvider ethers.js provider, an additional Provider to ethers.js to enable work with the gas model of LAC-NET.
Ethers.js v6 compatible

### Getting Started
Installation

npm i @lacchain/gas-model-provider


### Usage
``` javascript
import provider from "@lacchain/gas-model-provider";
import { LacchainProvider, LacchainSigner } from '@lacchain/gas-model-provider';

const provider = new provider.GasModelProvider( RPC_URL );
const signer = new provider.GasModelSigner( PRIVATE_KEY, provider, NODE_ADDRESS, EXPIRATION );
const provider = new LacchainProvider(RPC_URL);
const signer: LacchainSigner = new LacchainSigner(
PRIVATE_KEY,
provider,
NODE_ADDRESS,
EXPIRATION
);
```

Where:
Expand All @@ -21,13 +33,25 @@ Where:
#### Deploy smart contract

``` javascript
import ethers from "ethers";
import { ContractFactory } from 'ethers';
import { LacchainProvider, LacchainSigner } from '@lacchain/gas-model-provider';

const signer: LacchainSigner = new LacchainSigner(
PRIVATE_KEY,
new LacchainProvider(RPC_URL!),
NODE_ADDRESS!,
EXPIRATION
);

const contractFactory = new ContractFactory(
CONTRACT_ABI,
CONTRACT_BYTECODE,
signer
);

const factory = new ethers.ContractFactory( CONTRACT_ABI, CONTRACT_BYTECODE, signer )
const contract = await factory.deploy( { gasLimit: 100000, gasPrice: 0 } )
const receipt = await contract.deployTransaction.wait();
console.log( `Contract Address: ${receipt.contractAddress}` );
contractAddress = receipt.contractAddress;
const contract = await contractFactory.deploy();
const txReceipt = await contract.deploymentTransaction()?.wait();
console.log( `Contract Address: ${txReceipt?.contractAddress}` );
```
Where:
Expand All @@ -39,16 +63,22 @@ Where:
#### Invoke and call contract
``` javascript
const hash = "0x7465737400000000000000000000000000000000000000000000000000000000";
const contract = new ethers.Contract(CONTRACT_ADDRESS, CONTRACT_ABI, signer);
const tx = await contract.store(hash);
const receipt = await tx.wait();
console.log('Receipt', receipt);
const stored = await contract.retreiveHash(SENDER_ADDRESS);
console.log(stored);
import { Contract } from 'ethers';
import { LacchainProvider, LacchainSigner } from '@lacchain/gas-model-provider';
const signer: LacchainSigner = new LacchainSigner(
PRIVATE_KEY,
new LacchainProvider(RPC_URL!),
NODE_ADDRESS!,
EXPIRATION
);
const contract = new Contract(CONTRACT_ADDRESS, CONTRACT_ABI, signer);
await (await contract.someContractFunction()).wait();
```
Where:
- CONTRACT_ADDRESS: is the contract address
- CONTRACT_ABI: is the contract ABI
- SENDER_ADDRESS: is the sender address
2 changes: 2 additions & 0 deletions dist/ethers.js/src.ts/_admin/create-release.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=create-release.d.ts.map
1 change: 1 addition & 0 deletions dist/ethers.js/src.ts/_admin/create-release.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 51 additions & 0 deletions dist/ethers.js/src.ts/_admin/create-release.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/ethers.js/src.ts/_admin/create-release.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions dist/ethers.js/src.ts/_admin/generate-diffs.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=generate-diffs.d.ts.map
1 change: 1 addition & 0 deletions dist/ethers.js/src.ts/_admin/generate-diffs.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 41 additions & 0 deletions dist/ethers.js/src.ts/_admin/generate-diffs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/ethers.js/src.ts/_admin/generate-diffs.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions dist/ethers.js/src.ts/_admin/test-browser.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
*
*
* Paths
* /index.js => dist/ethers.js
* /tests/utils.js => in-memory hijack
* /static/* => output/*
* - index.html
* - assert.js
* /tests/* => lib.esm/_tests/*
*/
/// <reference types="node" />
import { WebSocket } from "ws";
import { Server } from "http";
export declare function getMime(filename: string): string;
export declare class CDPSession {
#private;
readonly websocket: WebSocket;
constructor(url: string);
get target(): string;
get ready(): Promise<void>;
get done(): Promise<number>;
send(method: string, params: any): Promise<any>;
_send(method: string, params: any): Promise<any>;
navigate(url: string): Promise<void>;
}
export type Options = {
port?: number;
redirects?: Record<string, string>;
};
export declare function start(_root: string, options: Options): Promise<Server>;
//# sourceMappingURL=test-browser.d.ts.map
1 change: 1 addition & 0 deletions dist/ethers.js/src.ts/_admin/test-browser.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit f0b07a2

Please sign in to comment.