Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: scripts to create and transfer energyweb
- Loading branch information
Showing
13 changed files
with
222 additions
and
7 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 @@ | ||
export const ewOwnerKey = "1aec3458500362c0a0f1772ab724a71b0f9d7da418a2d86d5954ab3f4b58ec4e"; | ||
|
||
export const ENERGYWEB = "energyweb"; | ||
export const IAM = "iam"; | ||
export const EWC = "ewc"; | ||
export const ENERGYWEB_ROOT = "tempenergywebowner2.dmitryfesenko.iam.ewc"; | ||
// export const ENERGYWEB_ROOT = `${ENERGYWEB}.${IAM}.${EWC}`; | ||
export const ENERGYWEB_OWNER = "did:ethr:volta:0xc56e810fE6715C6c6F0818bb16DAF1fE6A0121e2"; | ||
export const KYC_OWNER_DID = "did:ethr:ewc:0x246bDCF1e4f41FC639959FfAC135c77d9844750d"; | ||
|
||
export const ENERGYWEB_RECEIVER = "did:ethr:volta:0x8556c714BAB801FfB7292Bd73942460e79be83dE"; |
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,66 @@ | ||
import { VOLTA_CHAIN_ID } from "@energyweb/iam-contracts"; | ||
import { chainConfigs, initWithPrivateKeySigner } from "../src"; | ||
import { ENERGYWEB_OWNER, ENERGYWEB_ROOT, KYC_OWNER_DID } from "./constants"; | ||
|
||
/** | ||
* Creates apps and roles for the staking use case under the energyweb org | ||
* Assumes that the energyweb org is already created | ||
* For description of roles, see https://energyweb.atlassian.net/wiki/spaces/EWTS/pages/2960228364/SB+setup | ||
*/ | ||
|
||
const ewOwnerKey = "1aec3458500362c0a0f1772ab724a71b0f9d7da418a2d86d5954ab3f4b58ec4e"; | ||
const chainConfig = chainConfigs()[VOLTA_CHAIN_ID]; | ||
const rpcUrl = chainConfig.rpcUrl; | ||
|
||
(async function () { | ||
const { connectToCacheServer } = await initWithPrivateKeySigner(ewOwnerKey, rpcUrl); | ||
const { domainsService } = await connectToCacheServer(); | ||
|
||
const stakingApp = "staking"; | ||
await domainsService.createApplication({ | ||
appName: stakingApp, | ||
namespace: `apps.${ENERGYWEB_ROOT}`, | ||
data: { appName: stakingApp, websiteUrl: "https://staking-staging.energyweb.org/" }, | ||
}); | ||
console.log(`Application ${stakingApp} is created`); | ||
const verificationApp = "verification"; | ||
await domainsService.createApplication({ | ||
appName: verificationApp, | ||
namespace: `apps.${ENERGYWEB_ROOT}`, | ||
data: { appName: verificationApp }, | ||
}); | ||
console.log(`Application ${verificationApp} is created`); | ||
console.log("apps of energyweb root:", await domainsService.getAppsOfOrg(ENERGYWEB_ROOT)); | ||
|
||
const stakingOwnerRole = "owner"; | ||
await domainsService.createRole({ | ||
roleName: stakingOwnerRole, | ||
namespace: `roles.${stakingApp}.apps.${ENERGYWEB_ROOT}`, | ||
data: { | ||
roleName: stakingOwnerRole, | ||
roleType: "app", | ||
version: 1, | ||
enrolmentPreconditions: [], | ||
fields: [], | ||
metadata: {}, | ||
issuer: { issuerType: "DID", did: [ENERGYWEB_OWNER] }, | ||
}, | ||
}); | ||
console.log(`Role ${stakingOwnerRole} is created`); | ||
|
||
const emailRole = "email"; | ||
await domainsService.createRole({ | ||
roleName: emailRole, | ||
namespace: `roles.${verificationApp}.apps.${ENERGYWEB_ROOT}`, | ||
data: { | ||
roleName: emailRole, | ||
roleType: "app", | ||
version: 1, | ||
enrolmentPreconditions: [], | ||
fields: [], | ||
metadata: {}, | ||
issuer: { issuerType: "DID", did: [ENERGYWEB_OWNER, KYC_OWNER_DID] }, | ||
}, | ||
}); | ||
console.log(`Role ${emailRole} is created`); | ||
})(); |
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,16 @@ | ||
import { addressOf } from "@ew-did-registry/did-ethr-resolver"; | ||
import { chainConfigs, initWithPrivateKeySigner, VOLTA_CHAIN_ID } from "../src"; | ||
import { ENERGYWEB_RECEIVER, ENERGYWEB_ROOT, ewOwnerKey } from "./constants"; | ||
|
||
const rpcUrl = chainConfigs()[VOLTA_CHAIN_ID].rpcUrl; | ||
|
||
(async function () { | ||
const { connectToCacheServer } = await initWithPrivateKeySigner(ewOwnerKey, rpcUrl); | ||
const { domainsService } = await connectToCacheServer(); | ||
await domainsService.changeOrgOwnership({ | ||
namespace: ENERGYWEB_ROOT, | ||
newOwner: addressOf(ENERGYWEB_RECEIVER), | ||
returnSteps: false, | ||
withSubdomains: true, | ||
}); | ||
})(); |
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