-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into naynay/remove-programs
- Loading branch information
Showing
29 changed files
with
428 additions
and
117 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
export const version = 2 | ||
|
||
const targetKeys = new Set(['secretKey', 'publicKey', 'addressRaw']) | ||
|
||
export function migrate (data = {}) { | ||
if (!isObject(data)) return data | ||
if (isUI8A(data)) return data | ||
|
||
const initial = isArray(data) ? [] : {} | ||
|
||
return Object.entries(data).reduce((acc, [key, value]) => { | ||
if (targetKeys.has(key) && !isUI8A(value)) { | ||
acc[key] = objToUI8A(value) | ||
} | ||
else { | ||
acc[key] = migrate(value) | ||
} | ||
|
||
return acc | ||
}, initial) | ||
} | ||
|
||
|
||
function isObject (thing) { | ||
return typeof thing === 'object' | ||
} | ||
|
||
function isArray (thing) { | ||
return Array.isArray(thing) | ||
} | ||
|
||
function isUI8A (thing) { | ||
return thing instanceof Uint8Array | ||
} | ||
|
||
|
||
function objToUI8A (obj) { | ||
const bytes = Object.keys(obj) | ||
.sort((a, b) => Number(a) > Number(b) ? 1 : -1) | ||
.map(arrayIndex => obj[arrayIndex]) | ||
|
||
return new Uint8Array(bytes) | ||
} |
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,9 +1,11 @@ | ||
import * as migration00 from './00' | ||
import * as migration01 from './01' | ||
import * as migration02 from './02' | ||
|
||
const migrations = [ | ||
migration00, | ||
migration01, | ||
migration02, | ||
] | ||
|
||
export default migrations |
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,12 +1,8 @@ | ||
import * as config from '../../config' | ||
import { listAccounts } from './list' | ||
|
||
export async function cliListAccounts () { | ||
const storedConfig = await config.get() | ||
|
||
return storedConfig.accounts | ||
.map(account => ({ | ||
name: account.name, | ||
address: account.address, | ||
verifyingKeys: account?.data?.admin?.verifyingKeys | ||
})) | ||
return listAccounts(storedConfig) | ||
} |
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,25 @@ | ||
// @ts-ignore | ||
import Keyring from '@entropyxyz/sdk/keys' | ||
import { EntropyLogger } from 'src/common/logger'; | ||
import { EntropyAccountConfig } from "src/config/types"; | ||
|
||
export async function createAccount ({ name, seed, path }: { name: string, seed: string, path?: string }, logger?: EntropyLogger): Promise<EntropyAccountConfig> { | ||
const FLOW_CONTEXT = 'MANAGE_ACCOUNTS::CREATE_ACCOUNT' | ||
const keyring = new Keyring({ seed, path, debug: true }) | ||
const fullAccount = keyring.getAccount() | ||
// TO-DO: sdk should create account on constructor | ||
const { admin } = keyring.getAccount() | ||
logger?.debug('fullAccount:', FLOW_CONTEXT) | ||
logger?.debug(fullAccount, FLOW_CONTEXT) | ||
|
||
const data = fullAccount | ||
delete admin.pair | ||
// const encryptedData = password ? passwordFlow.encrypt(data, password) : data | ||
|
||
return { | ||
name: name, | ||
address: admin.address, | ||
// TODO: replace with data: encryptedData once pasword input is added back | ||
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
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
Oops, something went wrong.