Skip to content

Commit

Permalink
Merge pull request #6 from darwinia-network/multisig_accounts
Browse files Browse the repository at this point in the history
feat:multisig_accounts_migration
  • Loading branch information
wuminzhe authored Apr 7, 2023
2 parents ce0c2c9 + ceeff67 commit d2d0839
Show file tree
Hide file tree
Showing 40 changed files with 3,649 additions and 438 deletions.
86 changes: 86 additions & 0 deletions packages/app-config/src/abi/contract.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
[
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "addr",
"type": "address"
}
],
"name": "Deployed",
"type": "event"
},
{
"inputs": [],
"name": "bytecode",
"outputs": [
{
"internalType": "bytes",
"name": "",
"type": "bytes"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "public_key",
"type": "bytes32"
},
{
"internalType": "address[]",
"name": "owners",
"type": "address[]"
},
{
"internalType": "uint256",
"name": "threhold",
"type": "uint256"
}
],
"name": "computeAddress",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "public_key",
"type": "bytes32"
},
{
"internalType": "address[]",
"name": "owners",
"type": "address[]"
},
{
"internalType": "uint256",
"name": "threhold",
"type": "uint256"
}
],
"name": "deploy",
"outputs": [
{
"internalType": "address",
"name": "addr",
"type": "address"
}
],
"stateMutability": "nonpayable",
"type": "function"
}
]
11 changes: 11 additions & 0 deletions packages/app-config/src/chains/crab.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
import { ChainConfig } from "@darwinia/app-types";
import multisigContract from "../abi/contract.json";

export const crab: ChainConfig = {
name: "Crab",
displayName: "Crab",
explorerURLs: ["https://crab.subscan.io/"],
httpsURLs: ["https://crab-rpc.darwinia.network"],
kton: {
address: "0x0000000000000000000000000000000000000402",
symbol: "CKTON",
decimals: 9,
ethereumDecimals: 18,
},
ring: {
name: "CRAB",
symbol: "CRAB",
decimals: 9,
ethereumDecimals: 18,
},
contractAddresses: {
multisig: "0x227c3e01071C2429766dDec2267A613e32DD463e",
},
contractInterface: {
multisig: multisigContract,
},
chainId: 44,
prefix: 42,
Expand Down
15 changes: 13 additions & 2 deletions packages/app-config/src/chains/darwinia.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
import { ChainConfig } from "@darwinia/app-types";
import multisigContract from "../abi/contract.json";

export const darwinia: ChainConfig = {
name: "Darwinia",
displayName: "Darwinia",
explorerURLs: ["https://darwinia.subscan.io/"],
httpsURLs: ["https://rpc.darwinia.network"],
kton: {
address: "0x0000000000000000000000000000000000000402",
symbol: "KTON",
decimals: 18,
decimals: 9,
ethereumDecimals: 18,
},
ring: {
name: "RING",
symbol: "RING",
decimals: 18,
decimals: 9,
ethereumDecimals: 18,
},
contractAddresses: {
multisig: "0x227c3e01071C2429766dDec2267A613e32DD463e", //TODO update this accordingly
},
contractInterface: {
multisig: multisigContract,
},
chainId: 46,
prefix: 18,
Expand Down
11 changes: 11 additions & 0 deletions packages/app-config/src/chains/pangolin.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
import { ChainConfig } from "@darwinia/app-types";
import multisigContract from "../abi/contract.json";

export const pangolin: ChainConfig = {
name: "Pangolin",
displayName: "Pangolin",
explorerURLs: ["https://pangolin.subscan.io/"],
httpsURLs: ["https://pangolin-rpc.darwinia.network"],
kton: {
address: "0x0000000000000000000000000000000000000402",
symbol: "PKTON",
decimals: 9,
ethereumDecimals: 18,
},
ring: {
name: "PRING",
symbol: "PRING",
decimals: 9,
ethereumDecimals: 18,
},
contractAddresses: {
multisig: "0x227c3e01071C2429766dDec2267A613e32DD463e",
},
contractInterface: {
multisig: multisigContract,
},
chainId: 43,
prefix: 42,
Expand Down
11 changes: 11 additions & 0 deletions packages/app-config/src/chains/pangoro.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,29 @@
import { ChainConfig } from "@darwinia/app-types";
import multisigContract from "../abi/contract.json";

export const pangoro: ChainConfig = {
name: "Pangoro",
displayName: "Pangoro",
explorerURLs: ["https://pangoro.subscan.io/"],
httpsURLs: ["https://pangoro-rpc.darwinia.network"],
kton: {
address: "0x0000000000000000000000000000000000000402",
symbol: "OKTON",
name: "OKTON",
decimals: 9,
ethereumDecimals: 18,
},
ring: {
name: "ORING",
symbol: "ORING",
decimals: 9,
ethereumDecimals: 18,
},
contractAddresses: {
multisig: "0x6c25E0c1f57d7E78d7eB8D350f11204137EF71bE",
},
contractInterface: {
multisig: multisigContract,
},
chainId: 45,
prefix: 18,
Expand Down
22 changes: 22 additions & 0 deletions packages/app-config/src/gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,25 @@ export const FIND_MIGRATION_BY_SOURCE_ADDRESS = gql`
}
}
`;

export const FIND_MULTISIG_MIGRATION_BY_SOURCE_ADDRESS = gql`
query multisigMigrationQuery($accountAddress: String!) {
multisigAccountMigration(id: $accountAddress) {
id
params
blockTime
blockNumber
}
}
`;

export const FIND_MIGRATION_DESTINATION_PARAMS_BY_SOURCE_ADDRESS = gql`
query multisigDestinationMigrationQuery($accountAddress: String!) {
multisigDestinationAccount(id: $accountAddress) {
id
params
blockTime
blockNumber
}
}
`;
57 changes: 57 additions & 0 deletions packages/app-locale/src/localeKeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,62 @@ export const localeKeys = {
evmAccountNotFree: "evmAccountNotFree",
noTokensToMigrate: "noTokensToMigrate",
installWalletReminder: "installWalletReminder",
multisig: "multisig",
noMultisigAccounts: "noMultisigAccounts",
addMultisigAccount: "addMultisigAccount",
createWallet: "createWallet",
name: "Name",
threshold: "Threshold",
yourAddress: "yourAddress",
membersAddress: "membersAddress",
memberAddress: "memberAddress",
addMembers: "addMembers",
createMultisig: "createMultisig",
multisigCreationFailed: "multisigCreationFailed",
multisigNameTip: "multisigNameTip",
multisigThresholdTip: "multisigThresholdTip",
address: "address",
asset: "asset",
actions: "actions",
balanceAmount: "balanceAmount",
members: "members",
member: "member",
memberYou: "memberYou",
migration: "migration",
continue: "continue",
general: "general",
fromSubstrateMultisig: "fromSubstrateMultisig",
toEVMAccountDarwinia: "toEVMAccountDarwinia",
evmAccountFormat: "evmAccountFormat",
migrationNotice: "migrationNotice",
pending: "pending",
inProgress: "inProgress",
confirmedExtrinsic: "confirmedExtrinsic",
cancelledExtrinsics: "cancelledExtrinsics",
callHash: "callHash",
progress: "progress",
action: "action",
parameters: "parameters",
destination: "destination",
type: "type",
assets: "assets",
executed: "executed",
waitingDeploy: "waitingDeploy",
waitingDeployMessage: "waitingDeployMessage",
oneMoreStep: "oneMoreStep",
deploy: "deploy",
toCompleteMigration: "toCompleteMigration",
multisigMigrationSuccessful: "multisigMigrationSuccessful",
invalidName: "invalidName",
invalidThreshold: "invalidThreshold",
invalidMemberAddress: "invalidMemberAddress",
selectYourAddress: "selectYourAddress",
initialized: "initialized",
approved: "approved",
migrationFailed: "migrationFailed",
approve: "approve",
installEthereumWalletReminder: "installEthereumWalletReminder",
chainAdditionRejected: "chainAdditionRejected",
accountPermissionRejected: "accountPermissionRejected",
multisigAccountMigrationTitle: "multisigAccountMigrationTitle",
};
61 changes: 60 additions & 1 deletion packages/app-locale/src/translations/enUS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ const enUs = {
[localeKeys.darwiniaNetwork]: "Darwinia Network",
[localeKeys.connectWallet]: "Connect wallet",
[localeKeys.accountMigrationTitle]: `<span class="link link-primary">Darwinia 2.0</span> Account Migration`,
[localeKeys.accountMigrationInfo]: `Use account migration after Darwinia 2.0 upgrade to move your {{ringSymbol}}s and {{ktonSymbol}}s from the <span class="link link-primary">substrate account</span> to your <span class="link link-primary">EVM account</span>. Connect your wallet to view available migrations on your account.`,
[localeKeys.multisigAccountMigrationTitle]: `<span class="link link-primary">Darwinia 2.0</span> Multisig Account Migration`,
[localeKeys.accountMigrationInfo]: `Use account migration after Darwinia 2.0 upgrade to move your {{ringSymbol}}s and {{ktonSymbol}}s from the <span class="link link-primary">substrate account</span> to your <span class="link link-primary">EVM account</span>. Connect your wallet to view available migrations on your account. Click <a class="link link-primary" href={{multisigLink}}>here</a> for the migration of multisig accounts.`,
[localeKeys.bonded]: "Bonded",
[localeKeys.selectAccount]: "Select account",
[localeKeys.migrationSummaryInfo]:
Expand Down Expand Up @@ -55,7 +56,65 @@ const enUs = {
[localeKeys.evmAccountNotFree]: "This EVM account is not free",
[localeKeys.noTokensToMigrate]: `Selected account has no tokens to migrate`,
[localeKeys.installWalletReminder]: `Connection failed. Please install {{walletName}} <a target='_blank' class="link link-primary" href={{downloadURL}}>here</a>.`,
[localeKeys.multisig]: "Multisig",
[localeKeys.noMultisigAccounts]: "No data",
[localeKeys.addMultisigAccount]: "Add multisig",
[localeKeys.addMembers]: "Add Members",
[localeKeys.createWallet]: "Create wallet",
[localeKeys.name]: "Name",
[localeKeys.threshold]: "Threshold",
[localeKeys.yourAddress]: "Your address",
[localeKeys.memberAddress]: "Member address",
[localeKeys.membersAddress]: "Members addresses",
[localeKeys.addMembers]: "Add members",
[localeKeys.createMultisig]: "Create",
[localeKeys.multisigCreationFailed]: `Creation failed, unable to find the multisig account in Darwinia 1.0, please double-check the threshold and the addresses of all members.`,
[localeKeys.multisigNameTip]: `Arbitrary wallet name to help yourself remember.`,
[localeKeys.multisigThresholdTip]: `Minimum approvals required to validate the multi-sig transaction.`,
[localeKeys.address]: "Address",
[localeKeys.asset]: "Asset",
[localeKeys.actions]: "Actions",
[localeKeys.balanceAmount]: "{{amount}} {{tokenSymbol}}",
[localeKeys.members]: "Members",
[localeKeys.member]: "Member",
[localeKeys.memberYou]: "Member(You)",
[localeKeys.migration]: "Migration",
[localeKeys.continue]: "Continue",
[localeKeys.general]: "General",
[localeKeys.fromSubstrateMultisig]: "From The Substrate Multisig Account (Darwinia 1.0)",
[localeKeys.toEVMAccountDarwinia]: "To The EVM Account (Darwinia 2.0)",
[localeKeys.evmAccountFormat]: "EVM Account Format e.g. 0x267be1…",
[localeKeys.migrationNotice]:
"Please Ensure That You Have The Private Key For This EVM Account. And This Account Is Not From Any Third-Party Platform.",
[localeKeys.pending]: "Pending",
[localeKeys.inProgress]: "In Progress({{number}})",
[localeKeys.confirmedExtrinsic]: "Confirmed Extrinsics({{number}})",
[localeKeys.cancelledExtrinsics]: "Cancelled Extrinsics({{number}})",
[localeKeys.callHash]: "Call hash",
[localeKeys.progress]: "Progress",
[localeKeys.action]: "Action",
[localeKeys.parameters]: "Parameters",
[localeKeys.destination]: "Dest",
[localeKeys.type]: "Type",
[localeKeys.assets]: "Assets",
[localeKeys.executed]: "Executed",
[localeKeys.waitingDeploy]: "Waiting deploy",
[localeKeys.waitingDeployMessage]: `NOTE: This multisig account will need to be manually deployed on this page after the extrinsic is executed to complete the migration of the multi-signature account.`,
[localeKeys.oneMoreStep]: "One more step! Please click",
[localeKeys.deploy]: "Deploy",
[localeKeys.toCompleteMigration]: "to complete the migration of the multisig account.",
[localeKeys.multisigMigrationSuccessful]: `This Multisig account has been migrated successfully. Please note that version 2.0 still supports multisig, and you can use <a target='_blank' class="link link-primary" href={{link}}>Gnosis Safe Multisig - IPFS</a> to perform multisig operations on 2.0.`,
[localeKeys.invalidName]: "Invalid name",
[localeKeys.invalidThreshold]: "Invalid threshold",
[localeKeys.invalidMemberAddress]: "Invalid member address",
[localeKeys.selectYourAddress]: "Select your address",
[localeKeys.initialized]: "Initialized",
[localeKeys.approved]: "Approved",
[localeKeys.migrationFailed]: "Migration failed",
[localeKeys.approve]: "Approve",
[localeKeys.installEthereumWalletReminder]: `Connection failed. Please download {{walletName}} Extension <a target="_blank" class="link link-primary" href={{downloadURL}}>here</a>.`,
[localeKeys.chainAdditionRejected]: `Network mismatch, you can switch network manually in MetaMask.`,
[localeKeys.accountPermissionRejected]: `Account access permission rejected`,
};

export default enUs;
6 changes: 1 addition & 5 deletions packages/app-providers/src/hooks/useBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ import { useEffect, useState } from "react";
import { ApiPromise } from "@polkadot/api";
import { UnSubscription } from "../storageProvider";
import { Header } from "@polkadot/types/interfaces";

interface CurrentBlock {
number: number;
timestamp: number;
}
import { CurrentBlock } from "@darwinia/app-types";

const useBlock = (apiPromise: ApiPromise | undefined) => {
const [currentBlock, setCurrentBlock] = useState<CurrentBlock | undefined>();
Expand Down
Loading

0 comments on commit d2d0839

Please sign in to comment.