mirror of
https://github.com/pezkuwichain/pezkuwi-ui.git
synced 2026-05-31 11:01:03 +00:00
Sort who on multisig (#312)
This commit is contained in:
@@ -26,9 +26,9 @@
|
||||
"store": "^2.0.12"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^2.9.0-beta.0",
|
||||
"@polkadot/types": "^1.12.0-beta.5",
|
||||
"@polkadot/util": "^2.9.0-beta.0",
|
||||
"@polkadot/keyring": "^2.9.0-beta.1",
|
||||
"@polkadot/types": "^1.12.0-beta.6",
|
||||
"@polkadot/util": "^2.9.0-beta.1",
|
||||
"@types/ledgerhq__hw-transport-node-hid": "^4.22.1",
|
||||
"@types/ledgerhq__hw-transport-u2f": "^4.21.1",
|
||||
"@types/mkdirp": "^1.0.0",
|
||||
|
||||
@@ -10,7 +10,7 @@ import { CreateResult, KeyringAddress, KeyringAddressType, KeyringItemType, Keyr
|
||||
import BN from 'bn.js';
|
||||
import createPair from '@polkadot/keyring/pair';
|
||||
import chains from '@polkadot/ui-settings/defaults/chains';
|
||||
import { bnToBn, hexToU8a, isHex, isString } from '@polkadot/util';
|
||||
import { bnToBn, hexToU8a, isHex, isString, u8aSorted } from '@polkadot/util';
|
||||
import { createKeyMulti } from '@polkadot/util-crypto';
|
||||
|
||||
import env from './observable/development';
|
||||
@@ -45,7 +45,9 @@ export class Keyring extends Base implements KeyringStruct {
|
||||
|
||||
public addMultisig (addresses: (string | Uint8Array)[], threshold: BigInt | BN | number, meta: KeyringPair$Meta = {}): CreateResult {
|
||||
const address = createKeyMulti(addresses, threshold);
|
||||
const who = addresses.map((who) => this.encodeAddress(who));
|
||||
|
||||
// we could use `sortAddresses`, but rather use internal encode/decode so we are 100%
|
||||
const who = u8aSorted(addresses.map((who) => this.decodeAddress(who))).map((who) => this.encodeAddress(who));
|
||||
|
||||
return this.addExternal(address, { ...meta, isMultisig: true, threshold: bnToBn(threshold).toNumber(), who });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user