-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #57 from skalenetwork/schain-ima
Add predeployed IMA contracts to the typescript library
- Loading branch information
Showing
12 changed files
with
209 additions
and
8 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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export const PREDEPLOYED_ALIAS = "predeployed"; | ||
export const REPOSITORY_URL = "https://skalenetwork.github.io/skale-contracts/"; | ||
export const METADATA_FILENAME = "metadata.json"; |
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
59 changes: 59 additions & 0 deletions
59
typescript/base/src/projects/ima/schain/SchainImaInstance.ts
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,59 @@ | ||
import { ImaInstance } from "../ImaInstance"; | ||
|
||
|
||
export class SchainImaInstance<ContractType> extends | ||
ImaInstance<ContractType> { | ||
static PREDEPLOYED = new Map<string, string>([ | ||
[ | ||
"CommunityLocker", | ||
"0xD2aaa00300000000000000000000000000000000" | ||
], | ||
[ | ||
"KeyStorage", | ||
"0xd2aaa00200000000000000000000000000000000" | ||
], | ||
[ | ||
"MessageProxyForSchain", | ||
"0xd2AAa00100000000000000000000000000000000" | ||
], | ||
[ | ||
"ProxyAdmin", | ||
"0xd2aAa00000000000000000000000000000000000" | ||
], | ||
[ | ||
"TokenManagerERC1155", | ||
"0xD2aaA00900000000000000000000000000000000" | ||
], | ||
[ | ||
"TokenManagerERC20", | ||
"0xD2aAA00500000000000000000000000000000000" | ||
], | ||
[ | ||
"TokenManagerERC721", | ||
"0xD2aaa00600000000000000000000000000000000" | ||
], | ||
[ | ||
"TokenManagerERC721WithMetadata", | ||
"0xd2AaA00a00000000000000000000000000000000" | ||
], | ||
[ | ||
"TokenManagerEth", | ||
"0xd2AaA00400000000000000000000000000000000" | ||
], | ||
[ | ||
"TokenManagerLinker", | ||
"0xD2aAA00800000000000000000000000000000000" | ||
] | ||
]); | ||
|
||
getContractAddress (name: string): Promise<string> { | ||
if (name === "MessageProxyForSchain") { | ||
return Promise.resolve(this.address); | ||
} | ||
if (SchainImaInstance.PREDEPLOYED.has(name)) { | ||
return Promise.resolve(SchainImaInstance.PREDEPLOYED. | ||
get(name) as string); | ||
} | ||
throw new Error(`Can't get address of ${name} contract`); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
typescript/base/src/projects/ima/schain/SchainImaProject.ts
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,26 @@ | ||
import { ImaProject } from "../ImaProject"; | ||
import { Instance } from "../../../instance"; | ||
import { PREDEPLOYED_ALIAS } from "../../../domain/constants"; | ||
import { SchainImaInstance } from "./SchainImaInstance"; | ||
|
||
export class SchainImaProject<ContractType> extends | ||
ImaProject<ContractType> { | ||
getAbiFilename (version: string) { | ||
return `${this.metadata.name}-${version}-abi.json`; | ||
} | ||
|
||
getInstance (aliasOrAddress: string) { | ||
if (aliasOrAddress === PREDEPLOYED_ALIAS) { | ||
return this.createInstance(SchainImaInstance.PREDEPLOYED. | ||
get("MessageProxyForSchain")!); | ||
} | ||
return super.getInstance(aliasOrAddress); | ||
} | ||
|
||
createInstance (address: string): Instance<ContractType> { | ||
return new SchainImaInstance( | ||
this, | ||
address | ||
); | ||
} | ||
} |
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