-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🪚 OmniGraph™ Base SDKs - classes and interfaces (#96)
- Loading branch information
1 parent
2ec19b2
commit 5fd7196
Showing
10 changed files
with
76 additions
and
49 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
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
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from './coordinates' | ||
export * from './format' | ||
export * from './sdk' | ||
export * from './types' |
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,22 @@ | ||
import { OmniPoint, OmniTransaction } from '@layerzerolabs/utils' | ||
import { IOmniSDK, OmniContract } from './types' | ||
import { omniContractToPoint } from './coordinates' | ||
|
||
/** | ||
* Base class for all EVM SDKs, providing some common functionality | ||
* to reduce the boilerplate | ||
*/ | ||
export abstract class OmniSDK implements IOmniSDK { | ||
constructor(public readonly contract: OmniContract) {} | ||
|
||
get point(): OmniPoint { | ||
return omniContractToPoint(this.contract) | ||
} | ||
|
||
protected createTransaction(data: string): OmniTransaction { | ||
return { | ||
point: this.point, | ||
data, | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,8 +1,15 @@ | ||
import type { Contract } from '@ethersproject/contracts' | ||
import type { OmniPoint, WithEid } from '@layerzerolabs/utils' | ||
import type { IOmniSDK as IOmniSDKAbstract, OmniPoint, WithEid } from '@layerzerolabs/utils' | ||
|
||
export type OmniContract<TContract extends Contract = Contract> = WithEid<{ | ||
contract: TContract | ||
}> | ||
|
||
export type OmniContractFactory = (point: OmniPoint) => OmniContract | Promise<OmniContract> | ||
|
||
/** | ||
* Base interface for all EVM SDKs, adding the EVM specific attributes | ||
*/ | ||
export interface IOmniSDK extends IOmniSDKAbstract { | ||
contract: OmniContract | ||
} |
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